-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Open
Labels
c/subscriptions ✋Related to subscriptionsRelated to subscriptionsp/urgentImmediate action requiredImmediate action required
Description
subscription liveMatches {
matches(limit: 5, where: {status: {_eq: 3}}) {
id
}
}
I'm seeing responses on this query of anywhere from 1000ms to 3500ms, whereas the simpler version below returns in < 20ms. The table has an index on status. The table has a little over 1,000,000 rows, but this query has at most 5-100 nodes. I've noticed if the limit is above the total number of total nodes, it gets particularly slow. If the limit is beneath the number of nodes it's quite fast. I'm not sure if that relevance, but it may be helpful data.
Nested Loop Left Join (cost=0.56..0.60 rows=1 width=48)
-> Function Scan on _subs (cost=0.01..0.01 rows=1 width=48)
-> Subquery Scan on matches (cost=0.55..0.58 rows=1 width=32)
-> Aggregate (cost=0.55..0.56 rows=1 width=32)
-> Limit (cost=0.00..0.49 rows=5 width=32)
-> Seq Scan on matches matches_1 (cost=0.00..53376.58 rows=545002 width=32)
Filter: (status = ((_subs.result_vars #>> '{synthetic,0}'::text[]))::integer)
SubPlan 1
-> Result (cost=0.00..0.01 rows=1 width=32)
It appears as though it's using a seq scan for what should just be a simple index scan:
You can see once this query starts, it alone hammers my database:
I sent this out on Discord but didn't get a reply after 24h so I figured I'd share it here. Thanks.
gengue
Metadata
Metadata
Assignees
Labels
c/subscriptions ✋Related to subscriptionsRelated to subscriptionsp/urgentImmediate action requiredImmediate action required