Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix the SQL SELECT query in _paginate_room_events_txn #6340

Merged
merged 6 commits into from
Nov 8, 2019

Conversation

babolivier
Copy link
Contributor

@babolivier babolivier commented Nov 7, 2019

Doing a SELECT DISTINCT when paginating is quite expensive, because it requires the engine to do sorting on the entire events table. However, we only need to run it if we're filtering on 2+ labels, so this PR is changing the request so that DISTINCT is only used then.

Fixes #6337

Doing a SELECT DISTINCT when paginating is quite expensive, because it requires the engine to do sorting on the entire events table. However, we only need to run it if we're filtering on 2+ labels, so this PR is changing the request so that DISTINCT is only used then.
@babolivier babolivier requested a review from a team November 7, 2019 11:52
@richvdh
Copy link
Member

richvdh commented Nov 7, 2019

fixes #6337?

@babolivier
Copy link
Contributor Author

fixes #6337?

Ah, yes, I missed the issue

Copy link
Member

@erikjohnston erikjohnston left a comment

Choose a reason for hiding this comment

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

Let's get this merged to unbreak develop

synapse/storage/data_stores/main/stream.py Outdated Show resolved Hide resolved
synapse/storage/data_stores/main/stream.py Outdated Show resolved Hide resolved
@babolivier babolivier merged commit 963ffb6 into develop Nov 8, 2019
babolivier pushed a commit that referenced this pull request Sep 1, 2021
* commit '963ffb60b':
  Incorporate review
  Lint
  Only join on event_labels if we're filtering on labels
  Handle lack of filter
  Changelog
  Fix the SQL SELECT query in _paginate_room_events_txn
@babolivier babolivier deleted the babolivier/pagination_query branch October 28, 2021 15:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants