explain.depesz.com

PostgreSQL's explain analyze made readable

Result: TLdL

Settings
# exclusive inclusive rows x rows loops node
1. 271.467 1,464.639 ↓ 31.7 11,527 1

Unique (cost=44,394.45..44,398.09 rows=364 width=12) (actual time=1,010.590..1,464.639 rows=11,527 loops=1)

2. 384.317 1,193.172 ↓ 64.8 23,597 1

Sort (cost=44,394.45..44,395.36 rows=364 width=12) (actual time=1,010.571..1,193.172 rows=23,597 loops=1)

  • Sort Key: ad.document_id, r.field_id, wf.worksheet_id
  • Sort Method: quicksort Memory: 1875kB
3. 315.296 808.855 ↓ 64.8 23,597 1

Hash Join (cost=42,785.53..44,378.96 rows=364 width=12) (actual time=73.568..808.855 rows=23,597 loops=1)

  • Hash Cond: (r.field_id = wf.field_id)
4. 253.882 492.818 ↓ 20.7 15,642 1

Nested Loop (cost=42,784.21..44,371.18 rows=755 width=8) (actual time=72.782..492.818 rows=15,642 loops=1)

5. 13.582 92.856 ↓ 27.7 830 1

Unique (cost=42,783.93..42,784.23 rows=30 width=40) (actual time=72.682..92.856 rows=830 loops=1)

6.          

CTE all_docs

7. 14.480 49.800 ↑ 14.5 830 1

Recursive Union (cost=0.29..42,511.77 rows=12,063 width=50) (actual time=0.065..49.800 rows=830 loops=1)

8. 10.760 10.760 ↓ 1.2 830 1

Index Scan using documents_pkey on documents d (cost=0.29..1,562.64 rows=673 width=50) (actual time=0.033..10.760 rows=830 loops=1)

  • Index Cond: (document_id = ANY ('{16844,33497,18796,33453,16970,33580,16803,19935,33486,33475,33701,33539,17184,33465,33543,33285,33660,33626,33789,33875,33272,16343,33840,18658,33299,33669,33671,18985,33250,33302,18685,33845,19155,33576,18547,33632,33745,18003,33687,33709,33826,33372,33571,33283,33786,33834,33764,33598,33422,19038,33413,33673,33481,18570,33751,33458,33243,33541,33500,33766,18431,33870,33492,18409,33570,33263,33699,18518,33469,33560,33759,33451,17635,33796,33674,33483,33442,16759,33549,17704,33694,33861,33827,19187,18771,33305,33266,33809,33579,33371,33308,33557,33588,33360,33605,33688,33309,19864,33388,33406,33295,18847,33509,33494,33862,17261,33853,33879,33639,33737,33265,33866,33298,33301,33817,18857,33530,18047,17351,33872,33284,33583,33630,33649,33325,33850,33733,19770,33768,33439,17852,33608,33841,19062,33856,33741,17144,33411,17479,33643,33335,33504,33655,33513,33506,33680,33747,33427,33685,33607,33448,19646,33569,33313,16590,33339,33346,19103,33562,19815,33322,33291,33321,18061,33615,33867,19170,33276,33676,33697,33459,18534,33416,33702,33805,17681,33245,33548,33434,33754,18644,33409,33791,17225,33727,16383,33330,18826,33552,33761,33503,33743,18154,33387,16706,33277,16608,33502,33314,33278,33254,33713,33292,17409,33282,33369,18296,33728,33729,33763,33279,16830,33259,16420,33819,19686,33565,33444,17612,33816,33495,16659,33732,33395,33473,33359,33869,33290,19137,17804,18998,16316,33767,33715,33800,33742,33533,33255,17200,33636,33678,33654,33807,33714,33812,33683,33554,33462,33658,33659,33638,33288,33482,33467,33852,33724,33382,33744,19629,18132,19094,18280,33429,33556,33518,33700,33545,18838,33692,17569,33874,33445,16877,33835,33368,18963,19755,33389,19311,33323,33505,17511,33457,33410,33622,33609,33507,18906,33760,17691,17010,33603,33563,33452,33860,33581,33363,33613,33590,33833,33535,33691,33878,33491,33547,19501,16359,33650,33664,33851,33885,33304,33790,33865,18495,33647,33408,33472,33876,18090,18507,33249,17648,33398,33644,33597,19532,33336,33517,33351,33591,33756,33762,33799,33412,33589,33271,33289,33499,33386,33538,33821,19514,33365,33470,33792,19960,33803,19293,33635,33527,17395,33657,33525,33341,19826,19410,33859,33703,33575,33748,33717,33515,16325,18699,33707,33822,33293,33379,33824,33514,17464,33592,33731,16409,33577,33436,33275,33425,33787,33400,33319,18345,33268,33716,33373,33258,33586,33456,33450,33720,33378,33750,19360,33843,33540,33399,33795,33241,33582,33260,33280,33864,16688,33627,33698,17336,33247,33246,19670,16816,33831,33599,33842,33722,33438,33441,33239,16435,16742,33528,19586,33884,33594,33651,33383,17552,18264,17106,33661,33463,16676,33367,33567,33578,33356,33489,33446,17425,33393,33838,16782,33620,33573,33423,18634,33601,33558,33294,33546,19463,33662,33332,33550,33417,33740,33587,33568,16626,33488,33839,33823,33637,33863,33642,33648,33244,33730,33825,33345,19921,33646,33274,33828,33618,33337,19201,33375,33844,33616,19443,33815,33312,33267,33606,17826,18017,33390,33333,33708,18226,33808,17092,33536,18731,33612,19426,16950,33522,33435,33520,33810,33296,33326,33512,33357,33858,16961,33725,33466,33532,17525,33765,19989,33629,33354,33510,19394,33574,33634,33675,33719,18170,33370,18361,33437,33270,33407,33881,17437,17118,33704,33736,33686,33529,16392,33403,33420,33281,33447,33421,33461,18243,33380,33355,18558,33684,17717,17622,33868,18396,33404,33418,33364,33631,33248,33755,33477,33501,33794,33804,33739,18942,33877,33487,33871,33264,33426,33814,17536,33564,33625,33798,18745,33553,33376,33315,33752,33619,33348,18619,17748,33677,33534,17595,33793,33297,17174,17383,33829,33414,17586,33551,33256,33432,17452,33318,33480,33602,33362,19375,33873,33614,33624,17873,33449,33353,17784,17000,33391,33347,33785,33464,33544,33746,33252,33689,33251,33384,33572,33617,33640,17838,18032,33342,33758,19720,33854,33886,33524,33402,19488,33242,33595,19258,33882,33668,33443,33261,33682,33396,33269,33753,33584,16935,33710,33287,19331,16890,33667,33610,33381,33559,19944,16855,33521,33415,33496,33329,33476,17295,33257,33555,33286,33880,19791,33479,17157,33526,33665,33317,18674,33350,33670,33848,33358,18882,33855,33454,33690,33392,33734,33705,33801,33585,33430,33237,33672,33331,33846,33883,33474,17760,33344,19552,33471,17131,33334,33726,33490,33311,33374,33641,33797,16715,17056,33320,33652,33253,17024,19572,33310,33455,33561,33604,33836,33235,18078,33679,33485,33621,33857,19971,33327,19841,17367,19347,33516,33262,33723,16864,33338,33493,18757,33696,33511,33478,33401,33735,17664,33303,33849,33666,33653,17212,33428,33711,16911,33385,19121,19599,33352,18607,33596,18380,19015,33523,33802,33712,33340,19222,18316,33460,33397,33566,33405,33837,17071,33811,33433,33431,33695,33611,33366,33593,18183,33749,33498,33832,33440,18454,33468,18465,19706,33328,19082,33306,33324,33300,33508,33628,33645,17248,18921,18330,33361,33349,33681,33806,33623,33484,33663,33343,33316,33519,33307,33788,33656,33820,33377,33600,33757,33424,33813,33818,33693,33394,33738,33830,18199,33419,33537,33847,33273,33542,33721,33531,33633,33706,33718}'::integer[]))
  • Filter: (NOT soft_deleted)
9. 5.732 24.560 ↓ 0.0 0 1

Merge Join (cost=562.79..4,070.79 rows=1,139 width=50) (actual time=24.553..24.560 rows=0 loops=1)

  • Merge Cond: (d1.parent_id = ad_1.document_id)
10. 0.185 0.185 ↑ 1,566.8 18 1

Index Scan using doc_parent_id_idx on documents d1 (cost=0.29..3,392.74 rows=28,202 width=50) (actual time=0.016..0.185 rows=18 loops=1)

11. 12.249 18.643 ↑ 9.2 729 1

Sort (cost=562.51..579.33 rows=6,730 width=4) (actual time=13.036..18.643 rows=729 loops=1)

  • Sort Key: ad_1.document_id
  • Sort Method: quicksort Memory: 63kB
12. 6.394 6.394 ↑ 8.1 830 1

WorkTable Scan on all_docs ad_1 (cost=0.00..134.60 rows=6,730 width=4) (actual time=0.009..6.394 rows=830 loops=1)

13. 14.600 79.274 ↓ 27.7 830 1

Sort (cost=272.15..272.23 rows=30 width=40) (actual time=72.663..79.274 rows=830 loops=1)

  • Sort Key: ad.filename, ad.document_id, ad.processing_state
  • Sort Method: quicksort Memory: 89kB
14. 64.674 64.674 ↓ 27.7 830 1

CTE Scan on all_docs ad (cost=0.00..271.42 rows=30 width=40) (actual time=0.103..64.674 rows=830 loops=1)

  • Filter: ((NOT is_folder) AND (matter_id = 2))
15. 146.080 146.080 ↑ 1.3 19 830

Index Only Scan using res_document_id_field_id_idx on results r (cost=0.29..52.64 rows=25 width=8) (actual time=0.012..0.176 rows=19 loops=830)

  • Index Cond: (document_id = ad.document_id)
  • Heap Fetches: 15642
16. 0.378 0.741 ↓ 2.3 32 1

Hash (cost=1.14..1.14 rows=14 width=8) (actual time=0.733..0.741 rows=32 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 10kB
17. 0.363 0.363 ↓ 2.3 32 1

Seq Scan on worksheets_fields wf (cost=0.00..1.14 rows=14 width=8) (actual time=0.022..0.363 rows=32 loops=1)