Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirror
synapse
Commits
a8dbb624
Commit
a8dbb624
authored
Mar 9, 2015
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Optimize/coerce query to use correct indices
parent
d5174065
Loading
Loading
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/storage/stream.py
+12
-4
12 additions, 4 deletions
synapse/storage/stream.py
with
12 additions
and
4 deletions
synapse/storage/stream.py
+
12
−
4
View file @
a8dbb624
...
...
@@ -358,7 +358,7 @@ class StreamStore(SQLBaseStore):
sql
=
(
"
SELECT stream_ordering, topological_ordering, event_id
"
"
FROM events
"
"
WHERE room_id = ? AND
stream_ordering <= ? AND
outlier = 0
"
"
WHERE room_id = ? AND outlier = 0
"
"
ORDER BY topological_ordering DESC, stream_ordering DESC
"
"
LIMIT ?
"
)
...
...
@@ -368,21 +368,29 @@ class StreamStore(SQLBaseStore):
"
SELECT stream_ordering, topological_ordering, event_id
"
"
FROM events
"
"
WHERE room_id = ? AND stream_ordering > ?
"
"
AND
stream_ordering <= ? AND
outlier = 0
"
"
AND outlier = 0
"
"
ORDER BY topological_ordering DESC, stream_ordering DESC
"
"
LIMIT ?
"
)
def
get_recent_events_for_room_txn
(
txn
):
if
from_token
is
None
:
txn
.
execute
(
sql
,
(
room_id
,
end_token
.
stream
,
limit
,))
txn
.
execute
(
sql
,
(
room_id
,
limit
*
2
,))
else
:
txn
.
execute
(
sql
,
(
room_id
,
from_token
.
stream
,
end_token
.
stream
,
limit
room_id
,
from_token
.
stream
,
limit
*
2
))
rows
=
self
.
cursor_to_dict
(
txn
)
rows
[:]
=
[
r
for
r
in
rows
if
r
[
"
stream_ordering
"
]
<=
end_token
.
stream
]
rows
[:]
=
rows
[:
int
(
limit
)]
rows
.
reverse
()
# As we selected with reverse ordering
if
rows
:
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment