Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- postal=> EXPLAIN ANALYZE SELECT uuid from core_job where customer_id = 778449 and delivery_type = 'api' and date_created <= '2019-01-14 08:00:00+00' order by date_created desc limit 20;
- QUERY PLAN
- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
- Limit (cost=0.57..2522.42 rows=20 width=45) (actual time=0.023..0.073 rows=20 loops=1)
- -> Index Scan Backward using core_job_customer_id_date_created on core_job (cost=0.57..892358.66 rows=7077 width=45) (actual time=0.021..0.064 rows=20 loops=1)
- Index Cond: ((customer_id = 778449) AND (date_created <= '2019-01-14 08:00:00+00'::timestamp with time zone))
- Filter: ((delivery_type)::text = 'api'::text)
- Planning time: 1.527 ms
- Execution time: 0.100 ms
- (6 rows)
- postal=> EXPLAIN ANALYZE SELECT uuid from core_job where customer_id = 778449 and delivery_type = 'api' and date_created <= '2019-01-14 08:00:00+00'and id < 118938209 order by date_created desc, id desc limit 20;
- QUERY PLAN
- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- Limit (cost=686241.00..686241.05 rows=20 width=49) (actual time=1852.084..1852.096 rows=20 loops=1)
- -> Sort (cost=686241.00..686254.49 rows=5394 width=49) (actual time=1852.083..1852.088 rows=20 loops=1)
- Sort Key: date_created DESC, id DESC
- Sort Method: top-N heapsort Memory: 27kB
- -> Index Scan using core_job_customer_id_date_created on core_job (cost=0.57..686097.47 rows=5394 width=49) (actual time=0.087..1655.112 rows=272862 loops=1)
- Index Cond: ((customer_id = 778449) AND (date_created <= '2019-01-14 08:00:00+00'::timestamp with time zone))
- Filter: ((id < 118938209) AND ((delivery_type)::text = 'api'::text))
- Rows Removed by Filter: 39
- Planning time: 2.568 ms
- Execution time: 1852.139 ms
- (10 rows)
- postal=> EXPLAIN ANALYZE SELECT uuid from core_job where customer_id = 778449 and delivery_type = 'api' and id < 118938209 order by id desc limit 20;
- QUERY PLAN
- -----------------------------------------------------------------------------------------------------------------------------------------------------
- Limit (cost=0.57..43845.28 rows=20 width=41) (actual time=1.533..467.689 rows=20 loops=1)
- -> Index Scan Backward using core_job_pkey on core_job (cost=0.57..11855611.66 rows=5408 width=41) (actual time=1.531..467.662 rows=20 loops=1)
- Index Cond: (id < 118938209)
- Filter: ((customer_id = 778449) AND ((delivery_type)::text = 'api'::text))
- Rows Removed by Filter: 23070
- Planning time: 0.240 ms
- Execution time: 467.741 ms
- (7 rows)
Add Comment
Please, Sign In to add comment