-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for slow query on MS SQL #22522
base: main
Are you sure you want to change the base?
Fix for slow query on MS SQL #22522
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand it correctly, this completely removes the check which ensures that is_primary_key
and is_unique
are only set if index_column_count
and index_priority
are either 1 or NULL
. Can we really drop that?
My best guess for the slow query is that using a function and a comparison, that does not establish a relation between the joined tables, inside the ON
expression of a join somehow hits a slow path in Azure. Maybe moving the check into the subquery would help.
@nickrum, is this something the Directus team will investigate further, or would you like me to look into it more? I noticed the issue has been moved to 'ready,' so I'm curious about the status. |
I'm currently looking into it. I cannot reproduce the issue but that's only because I don't have a big and complex enough schema in my ms sql database. we're currently thinking about how we can spin up an arbitrary schema to do performance tests for introspection but right now it's tricky / time consuming. But I can confirm that the query in this PR does not return the same result as the current one. The one in this PR returns more records. I'll have to investigate now that this does not introduce any other problem. However, the fact that the PR does not introduce any additional integration tests to fail is a good sign that we can use the updated query :) |
I compared the query results further and noticed that the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as described above
@jaads How did you verify this? Is there a test setup I can use to further evaluate the query's outcome? I'm happy to help resolve this issue. It remains a significant problem in our Azure environment, especially when editing our data model, as we are doing this month for our production website. Each data model edit currently takes 30-60 seconds, which is quite disruptive. |
What's changed:
Potential Risks / Drawbacks
Review Notes / Questions
Fixes #19486
You can review the related issue here.
#19486