explain.depesz.com

PostgreSQL's explain analyze made readable

Result: NFZjw : Optimization for: plan #CSu5

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 619.953 619.953 ↓ 2.5 20 1

CTE Scan on clt (cost=12,854.64..12,854.80 rows=8 width=56) (actual time=619.936..619.953 rows=20 loops=1)

2.          

CTE clt

3. 0.004 619.947 ↓ 2.5 20 1

Subquery Scan on tmp_crm_last_touches (cost=12,851.70..12,854.64 rows=8 width=56) (actual time=619.934..619.947 rows=20 loops=1)

4. 0.008 619.943 ↓ 2.5 20 1

Unique (cost=12,851.70..12,854.56 rows=8 width=80) (actual time=619.933..619.943 rows=20 loops=1)

5. 0.035 619.935 ↑ 7.7 74 1

Sort (cost=12,851.70..12,853.13 rows=573 width=80) (actual time=619.932..619.935 rows=74 loops=1)

  • Sort Key: c.id, ec.executed_at DESC
  • Sort Method: quicksort Memory: 30kB
6. 0.043 619.900 ↑ 7.7 74 1

WindowAgg (cost=12,815.42..12,825.45 rows=573 width=80) (actual time=619.866..619.900 rows=74 loops=1)

7. 0.006 619.857 ↑ 7.7 74 1

Sort (cost=12,815.42..12,816.85 rows=573 width=24) (actual time=619.853..619.857 rows=74 loops=1)

  • Sort Key: c.id
  • Sort Method: quicksort Memory: 30kB
8. 36.208 619.851 ↑ 7.7 74 1

Gather (cost=1,053.45..12,789.17 rows=573 width=24) (actual time=20.737..619.851 rows=74 loops=1)

  • Workers Planned: 1
  • Workers Launched: 1
9. 291.821 583.643 ↑ 9.1 37 2 / 2

Nested Loop (cost=53.45..11,731.87 rows=337 width=24) (actual time=12.756..583.643 rows=37 loops=2)

  • Join Filter: (c.email && ARRAY[ece.email_address])
  • Rows Removed by Join Filter: 1154773
10. 0.486 2.942 ↓ 1.2 230 2 / 2

Hash Join (cost=53.02..2,394.75 rows=184 width=90) (actual time=0.203..2.942 rows=230 loops=2)

  • Hash Cond: (ec.brand = c.brand)
11. 2.339 2.339 ↑ 1.1 5,798 2 / 2

Parallel Seq Scan on email_campaigns ec (cost=0.00..2,262.82 rows=6,166 width=40) (actual time=0.004..2.339 rows=5,798 loops=2)

  • Filter: ((deleted_at IS NULL) AND (executed_at IS NOT NULL))
  • Rows Removed by Filter: 1158
12. 0.007 0.117 ↓ 2.5 20 2 / 2

Hash (cost=52.92..52.92 rows=8 width=82) (actual time=0.116..0.117 rows=20 loops=2)

  • Buckets: 1024 Batches: 1 Memory Usage: 11kB
13. 0.110 0.110 ↓ 2.5 20 2 / 2

Index Scan using contacts_pkey on contacts c (cost=0.43..52.92 rows=8 width=82) (actual time=0.020..0.110 rows=20 loops=2)

  • Index Cond: (id = ANY ('{b5e4b2d3-9089-4775-9f9b-02e6d8c049c7,4f5ded2f-93af-4c2c-a2ae-5e3e20451e72,9576a130-fe87-4018-a2ff-6228ee8c3c01,39532ccf-ee9a-41af-9ebb-0b0c5d5ca54b,2664d729-8370-4bf3-909a-5b7105797c44,8baaeeb3-0b2f-47ae-9270-46117f7c299a,9bf53581-e002-43a5-bb79-7f4a72f79aa2,5521d409-7a02-4b84-b000-32b35bf8df36,e711f35c-fb8a-4bfb-9524-490655f82432,15ef4b0c-09c1-4a96-9463-5a206e58108f,a2710f92-3ec8-4d30-8a1a-e0bbb40a8f21,adbdc076-8613-4c62-b79f-a9a72b585987,37283ce8-5cea-45ac-af76-5ab36bf63e74,098e2294-cec6-4268-9a11-dbd2cdcb3e1c,0ed97581-295b-47f5-8a12-249feef97433,92659f75-b16b-4f71-9779-24c37294a4a3,a62d2605-d7e2-4a27-b826-dc3d95cf3838,6cc9b863-09c8-4679-9ab1-f5d31e298298,9641653a-4f8c-44cf-8527-9ce9eddb1b5a,a391f180-e450-4ee5-964e-57df32cea46d}'::uuid[]))
  • Filter: (deleted_at IS NULL)
14. 288.880 288.880 ↓ 4.1 5,021 460 / 2

Index Scan using email_campaign_emails_campaign_idx on email_campaign_emails ece (cost=0.43..35.61 rows=12 -> Index Scan using email_campaign_emails_campaign_idx on email_campaign_emails ece (cost=0.43..35.61 rows=1,211 width=40) (actual time=0.003..1.256 rows=5,021 loops=460)

  • Index Cond: (campaign = ec.id)
Planning time : 0.975 ms
Execution time : 620.074 ms