explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 1n1R

Settings
# exclusive inclusive rows x rows loops node
1. 0.092 5,695.122 ↑ 8.4 1,189 1

Limit (cost=74,400.53..74,550.53 rows=10,000 width=50) (actual time=4,250.327..5,695.122 rows=1,189 loops=1)

2. 612.080 5,695.030 ↑ 21.7 1,189 1

Unique (cost=74,400.53..74,786.93 rows=25,760 width=50) (actual time=4,250.327..5,695.030 rows=1,189 loops=1)

3. 3,234.108 5,082.950 ↓ 124.8 3,215,585 1

Sort (cost=74,400.53..74,464.93 rows=25,760 width=50) (actual time=4,250.322..5,082.950 rows=3,215,585 loops=1)

  • Sort Key: agent_companies.company_name, agents.lastname, agents.firstname, agents.id, agents.promo_code
  • Sort Method: external merge Disk: 190120kB
4. 608.020 1,848.842 ↓ 124.8 3,215,585 1

Gather (cost=1,145.05..72,513.24 rows=25,760 width=50) (actual time=1.395..1,848.842 rows=3,215,585 loops=1)

  • Workers Planned: 1
  • Workers Launched: 1
5. 158.695 1,240.822 ↓ 106.1 1,607,792 2 / 2

Nested Loop (cost=145.05..68,937.24 rows=15,153 width=50) (actual time=0.601..1,240.822 rows=1,607,792 loops=2)

6. 0.247 12.057 ↓ 2.5 795 2 / 2

Nested Loop (cost=144.62..2,293.81 rows=321 width=50) (actual time=0.509..12.057 rows=795 loops=2)

7. 0.777 10.138 ↑ 1.6 209 2 / 2

Hash Join (cost=144.20..1,967.97 rows=342 width=25) (actual time=0.497..10.138 rows=209 loops=2)

  • Hash Cond: (agent_companies.ma_id = master_agents.id)
8. 8.948 8.948 ↑ 1.2 8,132 2 / 2

Parallel Seq Scan on agent_companies (cost=0.00..1,784.94 rows=9,444 width=29) (actual time=0.008..8.948 rows=8,132 loops=2)

  • Filter: ((NOT comm_only) AND (NOT inactive))
  • Rows Removed by Filter: 9972
9. 0.040 0.413 ↑ 1.0 296 2 / 2

Hash (cost=140.50..140.50 rows=296 width=4) (actual time=0.413..0.413 rows=296 loops=2)

  • Buckets: 1024 Batches: 1 Memory Usage: 19kB
10. 0.373 0.373 ↑ 1.0 296 2 / 2

Index Only Scan using master_agents_pkey on master_agents (cost=0.28..140.50 rows=296 width=4) (actual time=0.021..0.373 rows=296 loops=2)

  • Index Cond: (id = ANY ('{6158,3519,6810,2254,18577,5134,4198,4905,2838,3086,6819,644,6575,1389,12672,480,3492,2650,595,1958,2230,2004,2438,2183,6714,3853,13020,1427,5127,1776,1575,6618,6243,12926,17785,5899,2407,3900,5920,2408,16505,13698,876,5660,2777,5253,1426,6173,5359,1868,4235,3172,2291,4232,1438,1423,4231,2252,2548,5136,591,481,5896,2434,6812,2829,6541,2014,2253,6591,6231,6652,2960,592,5709,1421,13697,19599,2334,1539,13021,4185,1933,2427,4100,1502,2229,1777,13337,1718,479,3899,1744,1771,13332,13333,17784,6350,843,6244,19566,5532,5338,5323,2584,593,1766,6836,17783,2661,5194,6077,6456,19567,12976,4317,1844,6702,2088,13493,13334,3288,5363,1775,15077,5498,1352,1822,3287,422,3216,1870,6573,4906,4699,13593,6172,16399,4234,1548,1420,4281,3290,856,4293,3828,16368,18247,6395,18488,2228,4943,4184,1425,13528,6574,6177,2049,2119,5669,2333,6577,590,7718,1429,5429,4478,6572,17389,3170,2536,18246,5454,589,3285,1941,5723,3162,1869,2651,1738,6578,1778,585,6542,5710,3526,12974,2996,3963,19400,1413,5322,2400,1745,2402,1960,2235,17951,2292,6262,6617,12624,3397,3188,2239,15144,1719,3414,6396,4034,2547,1390,6478,645,3187,2660,2826,2142,5485,2467,1424,5102,1439,1929,2582,13002,6535,5662,5609,5264,5252,2090,1821,4395,3964,1954,1899,6039,2108,594,4199,1554,2575,6245,6557,2212,1428,6571,15803,6131,4033,13727,3289,12579,6146,15681,5364,4230,1959,6111,2172,13428,6109,12975,1443,3691,6543,1422,6509,7520,2419,586,2236,2831,4701,13032,6002,5330,18080,18575,583,3044,1391,1932,2215,895,4698,1855,12622,2653,3039,792,5365,18614,5517}'::integer[]))
  • Heap Fetches: 16
11. 1.672 1.672 ↓ 4.0 4 418 / 2

Index Scan using agents_promo_code_agent_company_id on agents (cost=0.42..0.94 rows=1 width=33) (actual time=0.004..0.008 rows=4 loops=418)

  • Index Cond: ((agent_company_id = agent_companies.id) AND (promo_code IS NOT NULL))
  • Filter: (NOT inactive)
  • Rows Removed by Filter: 1
12. 1,070.070 1,070.070 ↓ 1.1 2,022 1,590 / 2

Index Scan using client_companies_index_agent_id on client_companies (cost=0.43..189.51 rows=1,810 width=4) (actual time=0.007..1.346 rows=2,022 loops=1,590)

  • Index Cond: (agent_id = agents.id)
  • Filter: ((NOT inactive) AND (ma_company_id = 75))
  • Rows Removed by Filter: 0
Planning time : 1.477 ms
Execution time : 5,734.569 ms