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

Use index on int equal queries #3272

Merged
merged 4 commits into from
Apr 1, 2019
Merged

Conversation

jedelbo
Copy link
Contributor

@jedelbo jedelbo commented Apr 1, 2019

No description provided.

@jedelbo jedelbo requested a review from ironage April 1, 2019 16:02
@jedelbo jedelbo force-pushed the je/use_index_on_int_equal_queries branch 2 times, most recently from 9002f5c to 08e7795 Compare April 1, 2019 17:29
@jedelbo jedelbo force-pushed the je/use_index_on_int_equal_queries branch from 08e7795 to 4310b4a Compare April 1, 2019 17:31
@ironage
Copy link
Contributor

ironage commented Apr 1, 2019

Here's the benchmark results of this PR compared to core v5.18.0 using a column of 1 million unique integers.

Operation v5.18.0 (avg) This PR (avg) Approximate speedup
1000 conditions 230 ms 22 ms 10x
1000 conditions, indexed 231 ms 20 ms 10x
1 condition 615 us 370 us 1.6x
1 condition, indexed 617 us 15 us 40x

This shows a nice improvement across the board. The largest improvement in practice will be for users who chain many "OR" conditions together or heavily query an int primary key column (indexed automatically).

Copy link
Contributor

@ironage ironage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@ironage ironage merged commit b019a87 into master Apr 1, 2019
@astigsen
Copy link
Contributor

astigsen commented Apr 2, 2019 via email

@jedelbo
Copy link
Contributor Author

jedelbo commented Apr 2, 2019

If you have a 1000 conditions on a column with index, the query engine must visit 1000 nodes that each must lookup a value.
If you don't have an index, you will just have one node that will have to lookup 1 millon values in a hash table. This is most ly done in a tight loop.

@bmunkholm bmunkholm deleted the je/use_index_on_int_equal_queries branch April 2, 2019 19:46
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants