explain.depesz.com

PostgreSQL's explain analyze made readable

Result: qJXt

Settings
# exclusive inclusive rows x rows loops node
1. 0.758 56.156 ↓ 213.0 213 1

GroupAggregate (cost=12,398.37..12,398.41 rows=1 width=172) (actual time=55.285..56.156 rows=213 loops=1)

  • Group Key: grouped_impressions.cpm, grouped_impressions.loop_length, grouped_impressions.available_time, grouped_impressions.running_dates, grouped_impressions.start_time, grouped_impressions.end_time
2.          

CTE rate_card_multiple_cte

3. 0.031 0.031 ↓ 0.0 0 1

Seq Scan on rate_card_multiplier (cost=0.00..3.01 rows=1 width=629) (actual time=0.031..0.031 rows=0 loops=1)

  • Filter: (active AND (domain_id = 13))
  • Rows Removed by Filter: 98
4.          

CTE impressions

5. 7.267 49.353 ↓ 1,803.0 1,803 1

GroupAggregate (cost=12,394.92..12,395.25 rows=1 width=114) (actual time=41.988..49.353 rows=1,803 loops=1)

  • Group Key: screen.id, rate_card_schedule.cpm, su.loop_length, su.running_date, su.running_times, ss.audience_calculation_method
6. 0.747 42.086 ↓ 1,803.0 1,803 1

Sort (cost=12,394.92..12,394.93 rows=1 width=70) (actual time=41.941..42.086 rows=1,803 loops=1)

  • Sort Key: screen.id, rate_card_schedule.cpm, su.loop_length, su.running_date, su.running_times, ss.audience_calculation_method
  • Sort Method: quicksort Memory: 302kB
7. 0.291 41.339 ↓ 1,803.0 1,803 1

Nested Loop Left Join (cost=9,280.07..12,394.91 rows=1 width=70) (actual time=28.560..41.339 rows=1,803 loops=1)

8. 0.183 39.245 ↓ 1,803.0 1,803 1

Nested Loop Left Join (cost=9,279.80..12,394.55 rows=1 width=70) (actual time=28.553..39.245 rows=1,803 loops=1)

9. 1.544 37.259 ↓ 1,803.0 1,803 1

Nested Loop Left Join (cost=9,279.52..12,394.23 rows=1 width=70) (actual time=28.536..37.259 rows=1,803 loops=1)

  • Filter: ((_as.start_date IS NULL) AND (_as.end_date IS NULL) AND (_as.start_time IS NULL) AND (_as.end_time IS NULL))
10. 0.753 33.912 ↓ 225.4 1,803 1

Merge Join (cost=9,279.10..12,328.02 rows=8 width=62) (actual time=28.524..33.912 rows=1,803 loops=1)

  • Merge Cond: (su.screen_id = screen.id)
11. 0.889 29.574 ↓ 3.0 1,803 1

GroupAggregate (cost=9,278.81..9,296.87 rows=602 width=62) (actual time=28.514..29.574 rows=1,803 loops=1)

  • Group Key: su.screen_id, su.running_date, su.running_times, su.loop_length, ss.audience_calculation_method, rate_card_multiple_cte.multiplier
12. 0.703 28.685 ↓ 3.0 1,803 1

Sort (cost=9,278.81..9,280.32 rows=602 width=54) (actual time=28.509..28.685 rows=1,803 loops=1)

  • Sort Key: su.screen_id, su.running_date, su.running_times, su.loop_length, ss.audience_calculation_method, rate_card_multiple_cte.multiplier
  • Sort Method: quicksort Memory: 189kB
13. 0.359 27.982 ↓ 3.0 1,803 1

Nested Loop Left Join (cost=1.43..9,251.02 rows=602 width=54) (actual time=0.112..27.982 rows=1,803 loops=1)

  • Join Filter: ((su.running_date >= rate_card_multiple_cte.start_date) AND (su.running_date <= rate_card_multiple_cte.end_date))
14. 0.744 27.623 ↓ 3.0 1,803 1

Nested Loop (cost=1.43..9,235.96 rows=602 width=46) (actual time=0.081..27.623 rows=1,803 loops=1)

15. 0.000 23.273 ↓ 3.0 1,803 1

Nested Loop (cost=1.14..9,014.82 rows=602 width=54) (actual time=0.049..23.273 rows=1,803 loops=1)

16. 0.971 17.992 ↓ 3.0 1,803 1

Nested Loop (cost=0.85..8,767.62 rows=602 width=54) (actual time=0.038..17.992 rows=1,803 loops=1)

17. 13.415 13.415 ↓ 3.0 1,803 1

Index Scan using lean_screen_usage_unique_idx on lean_screen_usage su (cost=0.56..7,028.48 rows=602 width=50) (actual time=0.025..13.415 rows=1,803 loops=1)

  • Index Cond: ((screen_id = ANY ('{21939,21940,21941,21942,21943,21949,21950,21951,21952,21953,21954,21964,21965,21966,24940,24942,24943,24945,24949,24950,24973,24974,24989,24990,24991,24992,24993,24994,25001,25002,25005,25006,25011,25012,25013,25014,25027,25028,25037,25038,25041,25042,25043,25044,25045,25046,25047,25048,25069,25070,25077,25078,25081,25082,25083,25084,25085,25086,25087,25088,25089,25090,25105,25106,25109,25110,25117,25118,25119,25120,25139,25140,25512,25513,25524,25525,25560,25561,25568,25569,25602,25603,25608,25609,25610,25611,25622,25623,25626,25627,25642,25643,25646,25647,26083,26090,26093,26096,26103,26104,26107,26108,26111,26112,26115,26116,26135,26136,26141,26142,26151,26152,26171,26172,26175,26176,26183,26184,26185,26186,26191,26192,26193,26194,26195,26196,26199,26200,26203,26204,26205,26206,26207,26208,26209,26210,26225,26226,26227,26228,26233,26234,26241,26242,26245,26246,26247,26248,26249,26250,26267,26268,26269,26270,26273,26274,26275,26276,26281,26282,26285,26286,26289,26290,26311,26312,26315,26316,26317,26318,26321,26322,26329,26330,26331,26332,26333,26334,26353,26354,26355,26356,26371,26372,26373,26374,26379,26380,26381,26382,26397,26398,26399,26400,26403,26404,26413,26414,26415,26416,26417,26418,26423,26424,26429,26430,26437,26438,26439,26440,26441,26442,26445,26446,26447,26448,26449,26450,26451,26452,26455,26456,26457,26458,26459,26460,26463,26464,26465,26466,26471,26472,26479,26480,26481,26482,26483,26484,26487,26488,26489,26490,26495,26496,26501,26502,26503,26504,26505,26506,26513,26514,26517,26518,26519,26520,26521,26522,26523,26524,26529,26530,26533,26534,26543,26544,26547,26548,26549,26550,26551,26552,26557,26558,26559,26560,26561,26562,26565,26566,26567,26568,26569,26570,26573,26574,26575,26576,26581,26582,26583,26584,26589,26590,26591,26592,26597,26598,26599,26600,26601,26602,26603,26604,26605,26606,26607,26608,26609,26610,26615,26616,26617,26618,26623,26624,26625,26626,26627,26628,26631,26632,26635,26636,26639,26640,26641,26642,26645,26646,26647,26648,26649,26650,26653,26654,26655,26656,26657,26658,26661,26662,26663,26664,26665,26666,26667,26668,26677,26678,26685,26686,26687,26688,26705,26706,26709,26710,26711,26712,26713,26714,26715,26716,26719,26720,26721,26722,26727,26728,26729,26730,26731,26732,26735,26736,26737,26738,26739,26740,26741,26742,26747,26748,26749,26750,26759,26760,26761,26762,26763,26764,26765,26766,26767,26768,26769,26770,26773,26774,26775,26776,26815,26816,26817,26818,26821,26822,26823,26824,26845,26846,26847,26848,26857,26858,26861,26862,26865,26866,26875,26876,26877,26878,26881,26882,26883,26884,26885,26886,26889,26890,26891,26892,26893,26894,26899,26900,26903,26904,26909,26910,26911,26912,26913,26914,26915,26916,26919,26920,26921,26922,26923,26924,26933,26934,26935,26936,26937,26938,26939,26940,26941,26942,26945,26946,26951,26952,26971,26972,26983,26984,26987,26988,27033,27034,27039,27040,27041,27042,27045,27046,27047,27048,27051,27052,27053,27055,27056,27059,27060,27063,27064,27067,27068,27071,27072,27077,27078,27079,27080,27081,27082,27085,27086,27087,27088,27089,27090,27091,27092,27093,27094,27113,27114,27119,27120,27125,27126,27127,27128,27129,27130,27133,27134,27137,27143,27144,27145,27146,27147,27148,27149,27150,27153,27154,27155,27156,27159,27160,27161,27162,27171,27172,27177,27178,27179,27180,27181,27182,27195,27196,27199,27200,27201,27202,27203,27204,27237,27238,27249,27250,27255,27256,27257,27258,27261,27262,27263,27264,27265,27266,27271,27272,27273,27274,27275,27276,27281,27282,27283,27284,27285,27286,27287,27288,27289,27290,27291,27292,27293,27294,27297,27298,27299,27300,27301,27302,27303,27304,27307,27308,27309,27310,27311,27312,27313,27314,27315,27316,27317,27318,27319,27320,27321,27322,27323,27324,27325,27326,27327,27328,27329,27330,27333,27334,27339,27340,27341,27342,27347,27348,27349,27350,27351,27352,27361,27362,27377,27378,27383,27384,27385,27386,27387,27388,27389,27390,27401,27402,27409,27410,27423,27424,27427,27428,27433,27434,27435,27436,27447,27448,27449,27450,27451,27452,27455,27456,27457,27458,27459,27460,27465,27466,27475,27476,27477,27478,27481,27482,27483,27484,27485,27486,27487,27488,27489,27490,27491,27492,27493,27494,27495,27496,27497,27498,27499,27500,27501,27502,27503,27504,27507,27508,27525,27526,27527,27528,27529,27530,27531,27532,27533,27534,27535,27536,27539,27540,27541,27542,27543,27544,27545,27546,27547,27548,27549,27550,27553,27554,27555,27556,27557,27558,27559,27560,27565,27566,27569,27570,27571,27572,27573,27574,27575,27576,27577,27578,27581,27582,27583,27584,27585,27586,27587,27588,27589,27590,27592,27595,27596,27597,27598,27599,27600,27601,27602,27603,27604,27605,27606,27607,27608,27609,27610,27611,27612,27613,27614,27615,27616,27617,27618,27619,27620,27621,27622,27623,27624,27627,27628,27629,27630,27631,27632,27633,27634,27635,27636,27637,27638,27639,27640,27641,27642,27643,27644,27645,27646,27647,27648,27649,27650,27651,27652,27653,27654,27655,27656,27657,27658,27659,27660,27661,27662,27663,27664,27665,27666,27667,27668,27669,27670,27671,27672,27673,27674,27675,27676,27677,27678,27679,27680,27681,27682,27683,27684,27685,27686,27689,27690,27691,27692,27695,27696,27697,27698,27699,27700,27701,27702,27703,27704,27705,27706,27707,27708,27709,27710,27711,27712,27713,27714,27715,27716,27717,27718,27719,27720,27721,27722,27723,27724,27725,27726,27727,27728,27729,27730,27731,27732,27733,27734,27735,27736,27767,27768,27769,27770,27771,27772,27795,27796,27797,27798,27803,27804,27805,27806,27807,27808,27827,27828,27831,27832,27835,27836,27837,27838,27839,27840,27841,27842,27845,27846,27847,27848,27849,27850,27851,27852,27853,27854,27855,27856,27877,27878,27905,27906,27917,27918,27919,27920,27921,27922,27933,27934,27939,27940,27949,27950,27971,27972,27975,27976,27977,27978,27979,27980,27981,27982,27983,27984,27985,27986,27987,27988,27989,27990,27995,27996,27997,27998,28001,28002,28003,28004,28005,28006,28009,28010,28011,28012,28013,28014,28015,28016,28017,28018,28019,28020,28021,28022,28023,28024,28027,28028,28031,28032,28038,28049,28050,28051,28052,28053,28054,28055,28056,28067,28068,28073,28074,28079,28080,28081,28082,28083,28084,28085,28086,28087,28088,28089,28090,28091,28092,28093,28094,28095,28096,28097,28098,28099,28100,28101,28102,28103,28104,28109,28110,28111,28112,28113,28114,28127,28128,28129,28130,28131,28132,28133,28134,28139,28140,28141,28142,28143,28144,28149,28150,28151,28152,28157,28158,28159,28160,28181,28182,28191,28192,28195,28196,28197,28198,28199,28200,28201,28202,28203,28204,28213,28214,28219,28220,28221,28222,28251,28253,28258,28260,28266,28268,28270,28272,28274,28276,28278,28280,28299,28300,28302,28304,28311,28313,28331,28332,28333,28335,28342,28344,28346,28348,28465,28467,28472,28473,28474,28476,28479,28480,28489,28490,28492,28494,28495,28497,28499,28501,28514,28516,28518,28520,28526,28528,28530,28531,28536,28537,28546,28548,28557,28559,28561,28563,28573,28574,28576,28578,28580,28582,28584,28586,28588,28589,28625,28627,28636,28638,28657,28661,28763,28765,28789,28790,28810,28812,28815,28817,28819,28821,28824,28826,28827,28834,28835,28837,28840,28842,28843,28845,28847,28848,28850,28852,28854,28856,28861,28863,28883,28885,28887,28889,28891,28893,28926,28928,28934,28938,28944,28946,28948,28950,28983,28984,29190,29192,29213,29217,29219,29220,29245,29246,29253,29254,29257,29258,29259,29260,29261,29262,29263,29264,29273,29274,29277,29278,29281,29282,29283,29284,29287,29288,29291,29292,29293,29294,29295,29296,29297,29298,29300,29301,29304,29305,29312,29313,29314,29315,29316,29317,29318,29319,29320,29321,29324,29325,29328,29329,29336,29337,29631,29632,29668,29669,29672,29673,29687,29688,29695,29696,29699,29700,29701,29702,29703,29704,29705,29706,29707,29708,29709,29710,29713,29714,29762,29763,29764,29765,29766,29767,30908,30909,30942,30943,30944,30945,30946,30947,30950,30951,30954,30955,30966,30967,30975,30976,30977,30978,30979,30980,30989,30991,30999,31000,31006,31007,31009,31010,31011,31012,31019,31020,31021,31022,31035,31037,34636,34637,34640,34641,35254,35255,35256,35257,35258,35259,47639,47640,47643,47644,47645,47646,47647,47648,47649,47650}'::integer[])) AND (running_date >= '2019-09-08'::date) AND (running_date <= '2019-09-08'::date))
  • Filter: ((running_times && '[00:00:00,23:59:59)'::timerange) AND ((dow_mask & 127) > 0))
18. 3.606 3.606 ↑ 1.0 1 1,803

Index Scan using screen_schedule_pkey on screen_schedule ss (cost=0.29..2.88 rows=1 width=20) (actual time=0.002..0.002 rows=1 loops=1,803)

  • Index Cond: (id = su.screen_schedule_id)
19. 5.409 5.409 ↑ 1.0 1 1,803

Index Scan using screen_pkey on screen screen_1 (cost=0.29..0.40 rows=1 width=16) (actual time=0.002..0.003 rows=1 loops=1,803)

  • Index Cond: (id = ss.screen_id)
20. 3.606 3.606 ↑ 1.0 1 1,803

Index Only Scan using object_pkey on site (cost=0.29..0.36 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=1,803)

  • Index Cond: (id = screen_1.site_id)
  • Heap Fetches: 2290
21. 0.000 0.000 ↓ 0.0 0 1,803

CTE Scan on rate_card_multiple_cte (cost=0.00..0.02 rows=1 width=16) (actual time=0.000..0.000 rows=0 loops=1,803)

22. 3.585 3.585 ↓ 2.2 1,803 1

Index Scan using screen_pkey on screen (cost=0.29..3,021.51 rows=813 width=16) (actual time=0.008..3.585 rows=1,803 loops=1)

  • Index Cond: (id = ANY ('{21939,21940,21941,21942,21943,21949,21950,21951,21952,21953,21954,21964,21965,21966,24940,24942,24943,24945,24949,24950,24973,24974,24989,24990,24991,24992,24993,24994,25001,25002,25005,25006,25011,25012,25013,25014,25027,25028,25037,25038,25041,25042,25043,25044,25045,25046,25047,25048,25069,25070,25077,25078,25081,25082,25083,25084,25085,25086,25087,25088,25089,25090,25105,25106,25109,25110,25117,25118,25119,25120,25139,25140,25512,25513,25524,25525,25560,25561,25568,25569,25602,25603,25608,25609,25610,25611,25622,25623,25626,25627,25642,25643,25646,25647,26083,26090,26093,26096,26103,26104,26107,26108,26111,26112,26115,26116,26135,26136,26141,26142,26151,26152,26171,26172,26175,26176,26183,26184,26185,26186,26191,26192,26193,26194,26195,26196,26199,26200,26203,26204,26205,26206,26207,26208,26209,26210,26225,26226,26227,26228,26233,26234,26241,26242,26245,26246,26247,26248,26249,26250,26267,26268,26269,26270,26273,26274,26275,26276,26281,26282,26285,26286,26289,26290,26311,26312,26315,26316,26317,26318,26321,26322,26329,26330,26331,26332,26333,26334,26353,26354,26355,26356,26371,26372,26373,26374,26379,26380,26381,26382,26397,26398,26399,26400,26403,26404,26413,26414,26415,26416,26417,26418,26423,26424,26429,26430,26437,26438,26439,26440,26441,26442,26445,26446,26447,26448,26449,26450,26451,26452,26455,26456,26457,26458,26459,26460,26463,26464,26465,26466,26471,26472,26479,26480,26481,26482,26483,26484,26487,26488,26489,26490,26495,26496,26501,26502,26503,26504,26505,26506,26513,26514,26517,26518,26519,26520,26521,26522,26523,26524,26529,26530,26533,26534,26543,26544,26547,26548,26549,26550,26551,26552,26557,26558,26559,26560,26561,26562,26565,26566,26567,26568,26569,26570,26573,26574,26575,26576,26581,26582,26583,26584,26589,26590,26591,26592,26597,26598,26599,26600,26601,26602,26603,26604,26605,26606,26607,26608,26609,26610,26615,26616,26617,26618,26623,26624,26625,26626,26627,26628,26631,26632,26635,26636,26639,26640,26641,26642,26645,26646,26647,26648,26649,26650,26653,26654,26655,26656,26657,26658,26661,26662,26663,26664,26665,26666,26667,26668,26677,26678,26685,26686,26687,26688,26705,26706,26709,26710,26711,26712,26713,26714,26715,26716,26719,26720,26721,26722,26727,26728,26729,26730,26731,26732,26735,26736,26737,26738,26739,26740,26741,26742,26747,26748,26749,26750,26759,26760,26761,26762,26763,26764,26765,26766,26767,26768,26769,26770,26773,26774,26775,26776,26815,26816,26817,26818,26821,26822,26823,26824,26845,26846,26847,26848,26857,26858,26861,26862,26865,26866,26875,26876,26877,26878,26881,26882,26883,26884,26885,26886,26889,26890,26891,26892,26893,26894,26899,26900,26903,26904,26909,26910,26911,26912,26913,26914,26915,26916,26919,26920,26921,26922,26923,26924,26933,26934,26935,26936,26937,26938,26939,26940,26941,26942,26945,26946,26951,26952,26971,26972,26983,26984,26987,26988,27033,27034,27039,27040,27041,27042,27045,27046,27047,27048,27051,27052,27053,27055,27056,27059,27060,27063,27064,27067,27068,27071,27072,27077,27078,27079,27080,27081,27082,27085,27086,27087,27088,27089,27090,27091,27092,27093,27094,27113,27114,27119,27120,27125,27126,27127,27128,27129,27130,27133,27134,27137,27143,27144,27145,27146,27147,27148,27149,27150,27153,27154,27155,27156,27159,27160,27161,27162,27171,27172,27177,27178,27179,27180,27181,27182,27195,27196,27199,27200,27201,27202,27203,27204,27237,27238,27249,27250,27255,27256,27257,27258,27261,27262,27263,27264,27265,27266,27271,27272,27273,27274,27275,27276,27281,27282,27283,27284,27285,27286,27287,27288,27289,27290,27291,27292,27293,27294,27297,27298,27299,27300,27301,27302,27303,27304,27307,27308,27309,27310,27311,27312,27313,27314,27315,27316,27317,27318,27319,27320,27321,27322,27323,27324,27325,27326,27327,27328,27329,27330,27333,27334,27339,27340,27341,27342,27347,27348,27349,27350,27351,27352,27361,27362,27377,27378,27383,27384,27385,27386,27387,27388,27389,27390,27401,27402,27409,27410,27423,27424,27427,27428,27433,27434,27435,27436,27447,27448,27449,27450,27451,27452,27455,27456,27457,27458,27459,27460,27465,27466,27475,27476,27477,27478,27481,27482,27483,27484,27485,27486,27487,27488,27489,27490,27491,27492,27493,27494,27495,27496,27497,27498,27499,27500,27501,27502,27503,27504,27507,27508,27525,27526,27527,27528,27529,27530,27531,27532,27533,27534,27535,27536,27539,27540,27541,27542,27543,27544,27545,27546,27547,27548,27549,27550,27553,27554,27555,27556,27557,27558,27559,27560,27565,27566,27569,27570,27571,27572,27573,27574,27575,27576,27577,27578,27581,27582,27583,27584,27585,27586,27587,27588,27589,27590,27592,27595,27596,27597,27598,27599,27600,27601,27602,27603,27604,27605,27606,27607,27608,27609,27610,27611,27612,27613,27614,27615,27616,27617,27618,27619,27620,27621,27622,27623,27624,27627,27628,27629,27630,27631,27632,27633,27634,27635,27636,27637,27638,27639,27640,27641,27642,27643,27644,27645,27646,27647,27648,27649,27650,27651,27652,27653,27654,27655,27656,27657,27658,27659,27660,27661,27662,27663,27664,27665,27666,27667,27668,27669,27670,27671,27672,27673,27674,27675,27676,27677,27678,27679,27680,27681,27682,27683,27684,27685,27686,27689,27690,27691,27692,27695,27696,27697,27698,27699,27700,27701,27702,27703,27704,27705,27706,27707,27708,27709,27710,27711,27712,27713,27714,27715,27716,27717,27718,27719,27720,27721,27722,27723,27724,27725,27726,27727,27728,27729,27730,27731,27732,27733,27734,27735,27736,27767,27768,27769,27770,27771,27772,27795,27796,27797,27798,27803,27804,27805,27806,27807,27808,27827,27828,27831,27832,27835,27836,27837,27838,27839,27840,27841,27842,27845,27846,27847,27848,27849,27850,27851,27852,27853,27854,27855,27856,27877,27878,27905,27906,27917,27918,27919,27920,27921,27922,27933,27934,27939,27940,27949,27950,27971,27972,27975,27976,27977,27978,27979,27980,27981,27982,27983,27984,27985,27986,27987,27988,27989,27990,27995,27996,27997,27998,28001,28002,28003,28004,28005,28006,28009,28010,28011,28012,28013,28014,28015,28016,28017,28018,28019,28020,28021,28022,28023,28024,28027,28028,28031,28032,28038,28049,28050,28051,28052,28053,28054,28055,28056,28067,28068,28073,28074,28079,28080,28081,28082,28083,28084,28085,28086,28087,28088,28089,28090,28091,28092,28093,28094,28095,28096,28097,28098,28099,28100,28101,28102,28103,28104,28109,28110,28111,28112,28113,28114,28127,28128,28129,28130,28131,28132,28133,28134,28139,28140,28141,28142,28143,28144,28149,28150,28151,28152,28157,28158,28159,28160,28181,28182,28191,28192,28195,28196,28197,28198,28199,28200,28201,28202,28203,28204,28213,28214,28219,28220,28221,28222,28251,28253,28258,28260,28266,28268,28270,28272,28274,28276,28278,28280,28299,28300,28302,28304,28311,28313,28331,28332,28333,28335,28342,28344,28346,28348,28465,28467,28472,28473,28474,28476,28479,28480,28489,28490,28492,28494,28495,28497,28499,28501,28514,28516,28518,28520,28526,28528,28530,28531,28536,28537,28546,28548,28557,28559,28561,28563,28573,28574,28576,28578,28580,28582,28584,28586,28588,28589,28625,28627,28636,28638,28657,28661,28763,28765,28789,28790,28810,28812,28815,28817,28819,28821,28824,28826,28827,28834,28835,28837,28840,28842,28843,28845,28847,28848,28850,28852,28854,28856,28861,28863,28883,28885,28887,28889,28891,28893,28926,28928,28934,28938,28944,28946,28948,28950,28983,28984,29190,29192,29213,29217,29219,29220,29245,29246,29253,29254,29257,29258,29259,29260,29261,29262,29263,29264,29273,29274,29277,29278,29281,29282,29283,29284,29287,29288,29291,29292,29293,29294,29295,29296,29297,29298,29300,29301,29304,29305,29312,29313,29314,29315,29316,29317,29318,29319,29320,29321,29324,29325,29328,29329,29336,29337,29631,29632,29668,29669,29672,29673,29687,29688,29695,29696,29699,29700,29701,29702,29703,29704,29705,29706,29707,29708,29709,29710,29713,29714,29762,29763,29764,29765,29766,29767,30908,30909,30942,30943,30944,30945,30946,30947,30950,30951,30954,30955,30966,30967,30975,30976,30977,30978,30979,30980,30989,30991,30999,31000,31006,31007,31009,31010,31011,31012,31019,31020,31021,31022,31035,31037,34636,34637,34640,34641,35254,35255,35256,35257,35258,35259,47639,47640,47643,47644,47645,47646,47647,47648,47649,47650}'::integer[]))
  • Filter: active
23. 1.803 1.803 ↑ 18.0 1 1,803

Index Scan using idx_audience_schedule_screen on audience_schedule _as (cost=0.42..8.10 rows=18 width=40) (actual time=0.001..0.001 rows=1 loops=1,803)

  • Index Cond: (screen_id = screen.id)
24. 1.803 1.803 ↑ 1.0 1 1,803

Index Only Scan using rate_card_pkey on rate_card (cost=0.28..0.30 rows=1 width=8) (actual time=0.001..0.001 rows=1 loops=1,803)

  • Index Cond: (id = screen.rate_card_id)
  • Heap Fetches: 1693
25. 1.803 1.803 ↑ 1.0 1 1,803

Index Scan using rate_card_schedule_rate_card_id_idx on rate_card_schedule (cost=0.28..0.36 rows=1 width=16) (actual time=0.001..0.001 rows=1 loops=1,803)

  • Index Cond: (rate_card.id = rate_card_id)
26.          

CTE grouped_impressions

27. 3.021 53.183 ↓ 1,803.0 1,803 1

HashAggregate (cost=0.07..0.08 rows=1 width=116) (actual time=52.680..53.183 rows=1,803 loops=1)

  • Group Key: impressions.screen_id, impressions.cpm, impressions.loop_length, impressions.available_time, impressions.start_time, impressions.end_time
28. 50.162 50.162 ↓ 1,803.0 1,803 1

CTE Scan on impressions (cost=0.00..0.02 rows=1 width=84) (actual time=41.989..50.162 rows=1,803 loops=1)

29. 1.528 55.398 ↓ 1,803.0 1,803 1

Sort (cost=0.03..0.04 rows=1 width=116) (actual time=55.280..55.398 rows=1,803 loops=1)

  • Sort Key: grouped_impressions.cpm, grouped_impressions.loop_length, grouped_impressions.available_time, grouped_impressions.running_dates, grouped_impressions.start_time, grouped_impressions.end_time
  • Sort Method: quicksort Memory: 302kB
30. 53.870 53.870 ↓ 1,803.0 1,803 1

CTE Scan on grouped_impressions (cost=0.00..0.02 rows=1 width=116) (actual time=52.682..53.870 rows=1,803 loops=1)

Planning time : 28.605 ms
Execution time : 56.585 ms