Skip to content

Instantly share code, notes, and snippets.

@ailabs-software
Created September 14, 2019 19:32
Show Gist options
  • Save ailabs-software/ff0b2845925fbdd5af6c253209ad5a38 to your computer and use it in GitHub Desktop.
Save ailabs-software/ff0b2845925fbdd5af6c253209ad5a38 to your computer and use it in GitHub Desktop.
# SET work_mem = '400MB';
SET
# SHOW work_mem;
work_mem
----------
400MB
(1 row)
# EXPLAIN ANALYZE
SELECT maturation_timestamp FROM publish_queue LEFT OUTER JOIN publish ON(publish.id=publish_queue.publish_id) WHERE status_executed=0 AND funded AND syndicated=false ORDER BY NOT maturation_timestamp IS NULL, maturation_timestamp ASC LIMIT 1;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=177653.60..177653.60 rows=1 width=8) (actual time=1670.629..1670.629 rows=1 loops=1)
-> Sort (cost=177653.60..178960.77 rows=522867 width=8) (actual time=1670.627..1670.627 rows=1 loops=1)
Sort Key: ((publish_queue.maturation_timestamp IS NOT NULL)), publish_queue.maturation_timestamp
Sort Method: quicksort Memory: 25kB
-> Hash Join (cost=84400.05..175039.26 rows=522867 width=8) (actual time=1196.708..1670.620 rows=1 loops=1)
Hash Cond: (publish_queue.publish_id = publish.id)
-> Index Scan using publish_queue_status_executed_idx on publish_queue (cost=0.43..76977.85 rows=562209 width=24) (actual time=0.013..307.752 rows=584767 loops=1)
Index Cond: (status_executed = 0)
-> Hash (cost=68587.50..68587.50 rows=1264969 width=16) (actual time=1196.361..1196.361 rows=1218104 loops=1)
Buckets: 131072 Batches: 1 Memory Usage: 57099kB
-> Seq Scan on publish (cost=0.00..68587.50 rows=1264969 width=16) (actual time=0.003..590.025 rows=1218104 loops=1)
Filter: (funded AND (NOT syndicated))
Rows Removed by Filter: 89162
Total runtime: 1670.682 ms
(14 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment