explain.depesz.com

PostgreSQL's explain analyze made readable

Result: CSu5

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 730.488 730.488 ↑ 10.0 20 1

CTE Scan on clt (cost=15,732.55..15,736.55 rows=200 width=56) (actual time=730.470..730.488 rows=20 loops=1)

2.          

CTE clt

3. 0.004 730.482 ↑ 10.0 20 1

Subquery Scan on crm_last_touches (cost=15,726.45..15,732.55 rows=200 width=55) (actual time=730.469..730.482 rows=20 loops=1)

4. 0.008 730.478 ↑ 10.0 20 1

Unique (cost=15,726.45..15,730.55 rows=200 width=79) (actual time=730.467..730.478 rows=20 loops=1)

5. 0.035 730.470 ↑ 11.1 74 1

Sort (cost=15,726.45..15,728.50 rows=821 width=79) (actual time=730.467..730.470 rows=74 loops=1)

  • Sort Key: "*SELECT* 1".contact, "*SELECT* 1"."timestamp" DESC
  • Sort Method: quicksort Memory: 30kB
6. 0.042 730.435 ↑ 11.1 74 1

WindowAgg (cost=15,672.34..15,686.70 rows=821 width=79) (actual time=730.399..730.435 rows=74 loops=1)

7. 0.078 730.393 ↑ 11.1 74 1

Sort (cost=15,672.34..15,674.39 rows=821 width=55) (actual time=730.390..730.393 rows=74 loops=1)

  • Sort Key: "*SELECT* 1".contact
  • Sort Method: quicksort Memory: 30kB
8. 0.016 730.315 ↑ 11.1 74 1

Append (cost=0.71..15,632.60 rows=821 width=55) (actual time=114.014..730.315 rows=74 loops=1)

9. 0.000 0.530 ↓ 0.0 0 1

Subquery Scan on *SELECT* 1 (cost=0.71..360.56 rows=32 width=30) (actual time=0.530..0.530 rows=0 loops=1)

10. 0.001 0.530 ↓ 0.0 0 1

Nested Loop (cost=0.71..360.24 rows=32 width=46) (actual time=0.530..0.530 rows=0 loops=1)

11. 0.529 0.529 ↓ 0.0 0 1

Index Scan using crm_associations_contact_idx on crm_associations ca (cost=0.42..176.85 rows=87 width=32) (actual time=0.529..0.529 rows=0 loops=1)

  • Index Cond: (contact = 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)
12. 0.000 0.000 ↓ 0.0 0

Index Scan using crm_tasks_pkey on crm_tasks ct (cost=0.29..2.11 rows=1 width=30) (never executed)

  • Index Cond: (id = ca.crm_task)
  • Filter: ((deleted_at IS NULL) AND (task_type <> ALL ('{Note,Other}'::text[])) AND (due_date <= now()))
13. 0.001 1.237 ↓ 0.0 0 1

Subquery Scan on *SELECT* 2 (cost=161.72..1,392.28 rows=110 width=56) (actual time=1.237..1.237 rows=0 loops=1)

14. 0.000 1.236 ↓ 0.0 0 1

Nested Loop (cost=161.72..1,391.18 rows=110 width=72) (actual time=1.236..1.236 rows=0 loops=1)

15. 0.008 1.236 ↓ 0.0 0 1

Nested Loop (cost=0.70..205.02 rows=5 width=82) (actual time=1.236..1.236 rows=0 loops=1)

16. 0.568 0.568 ↓ 2.5 20 1

Index Scan using contacts_pkey on contacts (cost=0.43..52.92 rows=8 width=82) (actual time=0.015..0.568 rows=20 loops=1)

  • 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)
17. 0.660 0.660 ↓ 0.0 0 20

Index Scan using google_credentials_user_brand_email on google_credentials (cost=0.27..19.00 rows=1 width=32) (actual time=0.033..0.033 rows=0 loops=20)

  • Index Cond: (brand = contacts.brand)
  • Filter: ((deleted_at IS NULL) AND (revoked IS NOT TRUE))
18. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on google_messages (cost=161.02..236.64 rows=59 width=110) (never executed)

  • Recheck Cond: ((google_credential = google_credentials.id) AND (contacts.email && recipients))
  • Filter: (deleted_at IS NULL)
19. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on google_messages_credential_recipients_idx (cost=0.00..161.00 rows=68 width=0) (never executed)

  • Index Cond: ((google_credential = google_credentials.id) AND (contacts.email && recipients))
20. 0.001 103.058 ↓ 0.0 0 1

Subquery Scan on *SELECT* 3 (cost=192.33..1,251.87 rows=106 width=56) (actual time=103.058..103.058 rows=0 loops=1)

21. 0.051 103.057 ↓ 0.0 0 1

Nested Loop (cost=192.33..1,250.81 rows=106 width=72) (actual time=103.057..103.057 rows=0 loops=1)

22. 0.033 0.886 ↓ 5.0 20 1

Nested Loop (cost=0.70..201.72 rows=4 width=82) (actual time=0.050..0.886 rows=20 loops=1)

23. 0.133 0.133 ↓ 2.5 20 1

Index Scan using contacts_pkey on contacts contacts_1 (cost=0.43..52.92 rows=8 width=82) (actual time=0.008..0.133 rows=20 loops=1)

  • 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)
24. 0.720 0.720 ↑ 1.0 1 20

Index Scan using microsoft_credentials_user_brand_email on microsoft_credentials (cost=0.27..18.59 rows=1 width=32) (actual time=0.019..0.036 rows=1 loops=20)

  • Index Cond: (brand = contacts_1.brand)
  • Filter: ((deleted_at IS NULL) AND (revoked IS NOT TRUE))
  • Rows Removed by Filter: 1
25. 0.020 102.120 ↓ 0.0 0 20

Bitmap Heap Scan on microsoft_messages (cost=191.63..261.72 rows=55 width=124) (actual time=5.106..5.106 rows=0 loops=20)

  • Recheck Cond: ((microsoft_credential = microsoft_credentials.id) AND (contacts_1.email && recipients))
  • Filter: (deleted_at IS NULL)
26. 102.100 102.100 ↓ 0.0 0 20

Bitmap Index Scan on microsoft_messages_credential_recipients_idx (cost=0.00..191.61 rows=63 width=0) (actual time=5.105..5.105 rows=0 loops=20)

  • Index Cond: ((microsoft_credential = microsoft_credentials.id) AND (contacts_1.email && recipients))
27. 0.000 625.474 ↑ 7.7 74 1

Subquery Scan on *SELECT* 4 (cost=1,053.45..12,623.78 rows=573 width=56) (actual time=9.187..625.474 rows=74 loops=1)

28. 33.448 626.391 ↑ 7.7 74 1

Gather (cost=1,053.45..12,618.05 rows=573 width=72) (actual time=9.186..626.391 rows=74 loops=1)

  • Workers Planned: 1
  • Workers Launched: 1
29. 291.662 592.943 ↑ 9.1 37 2 / 2

Nested Loop (cost=53.45..11,560.75 rows=337 width=72) (actual time=12.815..592.943 rows=37 loops=2)

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

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

  • Hash Cond: (ec.brand = c.brand)
31. 2.380 2.380 ↑ 1.1 5,797 2 / 2

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

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

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

  • Buckets: 1024 Batches: 1 Memory Usage: 11kB
33. 0.107 0.107 ↓ 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.021..0.107 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)
34. 298.310 298.310 ↓ 4.3 5,021 460 / 2

Index Scan using email_campaign_emails_campaign_idx on email_campaign_emails ece (cost=0.43..35.07 rows=1,180 width=40) (actual time=0.003..1.297 rows=5,021 loops=460)

  • Index Cond: (campaign = ec.id)
Planning time : 2.411 ms
Execution time : 731.559 ms