If the input document is not validated against a schema, it is useful for Saxon to know this at compile time. When running from the command line, Saxon therefore sets the configuration switch config.setAllNodesUntyped(true) when running Saxon-B, or when running Saxon-SA without schema-awareness enabled. When running a user-written application, this switch is also set when using Saxon-B from Java, but not when using Saxon-B from .NET. A patch associated with this bug report fixes this.
The saving from setting this switch can be substantial: in a stylesheet currently under investigation, it gives a fourfold improvement under Java, and an eightfold improvement under .NET. It is not clear why the improvement should be different in the two cases. The saving comes because with untyped data, an expression such as [@value='ABC'] is always a singleton string comparison, whereas with typed data it might be a comparison of a list to a single string. This possibility can be elimated if type information is available at compile time, but not otherwise.
In order to avoid Saxon-SA users incurring a performance penalty when running untyped workloads, I will probably change the default in a future release so that this flag defaults to true in both Saxon-B and Saxon-SA. It will be set to false if the stylesheet or query imports a schema, or if the user explicitly requests it. I may also consider generating conditional code that contains a fast path for the case where the attribute value is a singleton. In the meantime, please not that the overhead is not incurred if type information is available: so Saxon-SA users in particular should take care to declare the types of variables and function parameters.