-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Use a query that postgresql optimises better for get_events_around #906
Conversation
LGTM |
@erikjohnston Having looked at how postgres handles the I've switched everything to use lower_bound/upper_bound from the streams.py and made those functions switch on the database engine to decide which format of SQL to use :( |
Can you elaborate? |
token.topological, "topological_ordering", | ||
token.topological, "topological_ordering", | ||
token.stream, "stream_ordering", | ||
token.stream, inclusive, "stream_ordering", |
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.
Is this not vulnerable to SQL injection?
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.
It would be if inclusive was ever specified by the user.
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.
I've made inclusive a boolean to make it a bit clearer. d44d11d
When I ran that query in a test harness it resulted in a scan over half the index.
Resulted in:
|
… sqli, and possibly make the code clearer
This presumably still has terrible performance on SQLite? |
Yes. Interestingly SQLite does a reasonable job of optimising the
|
So for a sqlite3 database only the UNION ALL form has the desired performance :(
|
Complete test harness for postgresql fwiw |
@erikjohnston PTAL |
LGTM |
No description provided.