Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Plain Text by AWizzArd ( 6 years ago )
-- runs in 15 secs:
explain SELECT deviceid, MAX(eventtime) FROM log.event WHERE deviceid IN (3847, 3848) GROUP BY deviceid;
==>
QUERY PLAN
Finalize GroupAggregate (cost=1354187.91..1354191.96 rows=16 width=16)
Group Key: deviceid
-> Gather Merge (cost=1354187.91..1354191.64 rows=32 width=16)
Workers Planned: 2
-> Sort (cost=1353187.88..1353187.92 rows=16 width=16)
Sort Key: deviceid
-> Partial HashAggregate (cost=1353187.40..1353187.56 rows=16 width=16)
Group Key: deviceid
-> Parallel Seq Scan on event (cost=0.00..1324178.67 rows=5801746 width=16)
Filter: (deviceid = ANY ('{3847,3848}'::bigint[]))
-- while this runs in 0,01 secs:
explain SELECT MAX(eventtime) FROM log.event WHERE deviceid IN (3847);
==>
QUERY PLAN
Result (cost=3.28..3.29 rows=1 width=8)
InitPlan 1 (returns $0)
-> Limit (cost=0.56..3.28 rows=1 width=8)
-> Index Only Scan Backward using idx_event_deviceid_eventtime on event (cost=0.56..20755559.59 rows=7630816 width=8)
Index Cond: ((deviceid = 3847) AND (eventtime IS NOT NULL))
Revise this Paste
Children: 105416