Skip to content

QP bottleneck due to type compatibility check. #472

@eriksunsol

Description

@eriksunsol

Starcounter version: 3.0.

Issue type

  • Bug

Issue description

We discovered a performance bottleneck in SC 3.0 which is not present in SC 2.3.1 LTS. The query processor attempts to verify that the type returned by a query is compatible with the generic type argument passed in ISqlContext.Sql<T>(string query, params object[] values). This type compatibility check uses reflection on the type argument apparently without caching the results.

In our case the compatibility check is not needed because we do not use tuples in this context. Anyway, we see a 25-50% performance penalty from this check alone (no exact numbers as tests were not run on isolated queries, but rather a real-world scenario with lots of other code). We are able to work around this by simply passing object as the type argument. In one scenario this small change reduced execution time of a complex algorithm from ~15 seconds to ~11 seconds. So the only change to get that improvement was instead of calling context.Sql<ActualType>("SQL...", args) we call context.Sql<object>("SQL...", args").Cast<ActualType>().

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions