explain.depesz.com

PostgreSQL's explain analyze made readable

Result: oMfn

Settings
# exclusive inclusive rows x rows loops node
1. 0.008 3.731 ↑ 1.0 1 1

Aggregate (cost=589.42..589.43 rows=1 width=32) (actual time=3.731..3.731 rows=1 loops=1)

2.          

CTE ids_with_same_ko_key

3. 0.267 0.267 ↑ 1.0 1 1

Seq Scan on generated_cards_data_1005 (cost=0.00..137.47 rows=1 width=8) (actual time=0.188..0.267 rows=1 loops=1)

  • Filter: ((ko_key = '-495'::text) AND ((card_id = 1) OR (card_id = 30)))
  • Rows Removed by Filter: 69
4.          

CTE ids_with_same_abs_ko_key

5. 0.159 0.159 ↓ 2.0 2 1

Seq Scan on generated_cards_data_1005 generated_cards_data_1005_1 (cost=0.00..138.52 rows=1 width=8) (actual time=0.105..0.159 rows=2 loops=1)

  • Filter: ((date >= CURRENT_DATE) AND ((card_id = 1) OR (card_id = 30)) AND (abs((ko_key)::integer) = 495))
  • Rows Removed by Filter: 68
6.          

CTE exclude_cards_with_actions

7. 0.004 0.485 ↑ 1.0 1 1

Nested Loop (cost=0.49..7.08 rows=1 width=4) (actual time=0.475..0.485 rows=1 loops=1)

8. 0.003 0.447 ↑ 1.0 2 1

Unique (cost=0.07..0.08 rows=2 width=8) (actual time=0.444..0.447 rows=2 loops=1)

9. 0.012 0.444 ↓ 1.5 3 1

Sort (cost=0.07..0.08 rows=2 width=8) (actual time=0.444..0.444 rows=3 loops=1)

  • Sort Key: ids_with_same_ko_key.id
  • Sort Method: quicksort Memory: 25kB
10. 0.002 0.432 ↓ 1.5 3 1

Append (cost=0.00..0.06 rows=2 width=8) (actual time=0.190..0.432 rows=3 loops=1)

11. 0.269 0.269 ↑ 1.0 1 1

CTE Scan on ids_with_same_ko_key (cost=0.00..0.02 rows=1 width=8) (actual time=0.190..0.269 rows=1 loops=1)

12. 0.161 0.161 ↓ 2.0 2 1

CTE Scan on ids_with_same_abs_ko_key (cost=0.00..0.02 rows=1 width=8) (actual time=0.106..0.161 rows=2 loops=1)

13. 0.034 0.034 ↓ 0.0 0 2

Index Scan using generated_cards_users_generated_card_id_user_id_uindex on generated_cards_users_actions (cost=0.42..3.48 rows=1 width=4) (actual time=0.016..0.017 rows=0 loops=2)

  • Index Cond: (generated_card_id = ids_with_same_ko_key.id)
  • Filter: (((snoozed_at IS NOT NULL) OR (latest_comment IS NOT NULL) OR (done IS NOT NULL) OR (saved IS NOT NULL)) AND (site_id = 1005))
14.          

CTE exclude_cards_with_shares

15. 1.787 3.229 ↓ 0.0 0 1

Hash Join (cost=0.13..305.98 rows=5 width=4) (actual time=3.229..3.229 rows=0 loops=1)

  • Hash Cond: (shared_cards.generated_card_id = ids_with_same_ko_key_1.id)
16. 1.429 1.429 ↓ 1.0 7,192 1

Seq Scan on shared_cards (cost=0.00..215.55 rows=7,155 width=4) (actual time=0.004..1.429 rows=7,192 loops=1)

17. 0.002 0.013 ↑ 1.0 2 1

Hash (cost=0.10..0.10 rows=2 width=8) (actual time=0.013..0.013 rows=2 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
18. 0.002 0.011 ↑ 1.0 2 1

Unique (cost=0.07..0.08 rows=2 width=8) (actual time=0.009..0.011 rows=2 loops=1)

19. 0.005 0.009 ↓ 1.5 3 1

Sort (cost=0.07..0.08 rows=2 width=8) (actual time=0.008..0.009 rows=3 loops=1)

  • Sort Key: ids_with_same_ko_key_1.id
  • Sort Method: quicksort Memory: 25kB
20. 0.002 0.004 ↓ 1.5 3 1

Append (cost=0.00..0.06 rows=2 width=8) (actual time=0.001..0.004 rows=3 loops=1)

21. 0.001 0.001 ↑ 1.0 1 1

CTE Scan on ids_with_same_ko_key ids_with_same_ko_key_1 (cost=0.00..0.02 rows=1 width=8) (actual time=0.001..0.001 rows=1 loops=1)

22. 0.001 0.001 ↓ 2.0 2 1

CTE Scan on ids_with_same_abs_ko_key ids_with_same_abs_ko_key_1 (cost=0.00..0.02 rows=1 width=8) (actual time=0.000..0.001 rows=2 loops=1)

23. 0.005 3.723 ↑ 6.0 1 1

HashAggregate (cost=0.20..0.26 rows=6 width=4) (actual time=3.723..3.723 rows=1 loops=1)

  • Group Key: exclude_cards_with_actions.generated_card_id
24. 0.001 3.718 ↑ 6.0 1 1

Append (cost=0.00..0.18 rows=6 width=4) (actual time=0.477..3.718 rows=1 loops=1)

25. 0.488 0.488 ↑ 1.0 1 1

CTE Scan on exclude_cards_with_actions (cost=0.00..0.02 rows=1 width=4) (actual time=0.477..0.488 rows=1 loops=1)

26. 3.229 3.229 ↓ 0.0 0 1

CTE Scan on exclude_cards_with_shares (cost=0.00..0.10 rows=5 width=4) (actual time=3.229..3.229 rows=0 loops=1)

Planning time : 0.775 ms