fix: use optimized SQL when selecting non-hidden entries#1240
Conversation
|
After researching the problem, I've come to the conclusion, that while this works well for me, it's not generally true, and ensuring Indices exist for tag_entries might be a more reasonable approach. |
|
I implemented the optimal solution suggested by BobBobs on Discord. In my limited testing both without any hidden and with thousands it appears to perform really well. |
|
I'm fairly certain #1129 will resolve this issue is a much better way |
|
As requested I've reopened this. Though I'm not sure if this is needed when Indices are added |
CyanVoxel
left a comment
There was a problem hiding this comment.
Thank you for your work on this!
Summary
This fixes #1239 by rewriting the sqlalchemy code that fetches non-hidden entries. Such that references to the main query are no longer used in the sub-query. This is done in 2 steps:
This is done by first querying all tags that are hidden and joining with the TagEntry binding table and selecting only the entry ids.
Previous generated SQL for simple query:
New SQL (edited to match current version):
Tasks Completed
Reused existing tests, as this should be a "do the same but faster"