Add special optimization of ExternalSourceAspect and remove some unnecessary code#1106
Add special optimization of ExternalSourceAspect and remove some unnecessary code#1106
Conversation
I'll try to find some time for this ASAP, but that'll probably only happen next week. |
|
Not good... Here're the results:
This is for a test defined here: https://github.com/iTwin/presentation-performance-tests/blob/d7d9e4db41b2e3b3ac92a636fff3ddfd05614676/src/tests/ContentDescriptor.test.mts#L14. The library runs a number of queries for this request, I haven't investigated further which queries exactly got slower. |
|
@khanaffan, based on our internal discussion, I re-ran the test on the test iModels after running |
Closes: https://github.com/iTwin/itwinjs-backlog/issues/1479
Changes
This query optimization involves ExternalSourceAspect, which is typically slow. A previously mentioned method was suggested to accelerate its performance.
Reason:
ExternalSourceAspect.Element.Id is associated with the index (ix_bis_ElementMultiAspect_fk_bis_ElementOwnsMultiAspects_target), which closely matches Element.Id. Consequently, using this index for looping yields performance akin to a SCAN operation. Therefore, the index should be used as a last resort, not as a primary or secondary option.
The patch identifies the search expression 'ExternalSourceAspect.Element.Id' and appends a '+' to invalidate it. Some earlier optimizations related to this have been eliminated.