Skip to content

Instantly share code, notes, and snippets.

@ailabs-software
Created September 15, 2019 03:03
Show Gist options
  • Save ailabs-software/6739058b82649a7ac3373a8fa256407c to your computer and use it in GitHub Desktop.
Save ailabs-software/6739058b82649a7ac3373a8fa256407c to your computer and use it in GitHub Desktop.
# EXPLAIN ANALYZE SELECT COUNT(*) FROM publish_queue WHERE NOT EXISTS(SELECT 1 FROM publish WHERE id = publish_queue.publish_id);
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=444595.43..444595.44 rows=1 width=0) (actual time=4001.970..4001.970 rows=1 loops=1)
-> Merge Anti Join (cost=368.56..444595.43 rows=1 width=0) (actual time=4001.967..4001.967 rows=0 loops=1)
Merge Cond: (publish_queue.publish_id = publish.id)
-> Index Only Scan using publish_queue_publish_id_idx on publish_queue (cost=0.56..226422.09 rows=9668693 width=16) (actual time=0.021..2199.928 rows=9726503 loops=1)
Heap Fetches: 3223208
-> Materialize (cost=0.43..52748.07 rows=1363712 width=16) (actual time=0.021..748.013 rows=1308839 loops=1)
-> Index Only Scan using publish_id_idx on publish (cost=0.43..49338.79 rows=1363712 width=16) (actual time=0.018..585.066 rows=1308839 loops=1)
Heap Fetches: 474697
Total runtime: 4002.004 ms
(9 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment