Skip to content
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

Patch 5 repro #264

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open

Patch 5 repro #264

wants to merge 22 commits into from

Conversation

Rochet2
Copy link

@Rochet2 Rochet2 commented Sep 24, 2023

TODO: explain

@Rochet2
Copy link
Author

Rochet2 commented Sep 24, 2023

"create more clear case": https://github.com/sequelize/sequelize-sscce/actions/runs/6290931879/job/17078814349#step:7:83
EXISTS is way slower

"Maybe we have special case?": https://github.com/sequelize/sequelize-sscce/actions/runs/6290993557/job/17078936600#step:7:83
EXISTS is way faster

The difference between the two commits is that the bars is being limited to a smaller set of records
where: { id: { [Op.gt]: 123 } } VS where: { id: { [Op.between]: [2345, 8678] } }

This indicates that EXISTS is only faster if the inner subquery (bars) returns same amount or less rows than then outer query (foos).


Also interestingly, postgres 9.5, 10, 11 all take around 500-700ms with EXISTS and 2000ms with IS NOT NULL to execute "Maybe its our postgres version?".
But when we try the same case on postgres 12 or 16, the EXISTS version of the query drops down to 20ms. There were clearly some optimizations done in postgres 12.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant