| 145 | | JOIN "Regular_User" ru ON u.user_id = ru.user_id |
| 146 | | JOIN "Ticket_Order" o ON ru.user_id = o.user_id |
| 147 | | JOIN "Ticket_Order_Item" toi ON o.order_id = toi.order_id |
| 148 | | JOIN "Ticket" t ON toi.ticket_id = t.ticket_id |
| 149 | | JOIN "Event_Happening" eh ON t.event_happening_id = eh.event_happening_id |
| 150 | | JOIN "Event" e ON eh.event_id = e.event_id |
| 151 | | LEFT JOIN "Ticket_Refund_Item" tri ON toi.order_item_id = tri.order_item_id |
| 152 | | LEFT JOIN "Ticket_Refund" tr ON tri.refund_id = tr.refund_id; |
| 153 | | |
| 154 | | }}} |
| 155 | | |
| 156 | | Погледот е веќе најоптимално напишан и не треба да се преуредува. |
| | 136 | JOIN "Regular_User" ru ON u.user_id = ru.user_id |
| | 137 | JOIN "Ticket_Order" o ON ru.user_id = o.user_id |
| | 138 | JOIN "Ticket_Order_Item" toi ON o.order_id = toi.order_id |
| | 139 | JOIN "Ticket" t ON toi.ticket_id = t.ticket_id |
| | 140 | JOIN "Event_Happening" eh ON t.event_happening_id = eh.event_happening_id |
| | 141 | JOIN "Event" e ON eh.event_id = e.event_id |
| | 142 | LEFT JOIN "Ticket_Refund_Item" tri ON toi.order_item_id = tri.order_item_id |
| | 143 | LEFT JOIN "Ticket_Refund" tr ON tri.refund_id = tr.refund_id |
| | 144 | WHERE u.is_active = TRUE; |
| | 145 | |
| | 146 | }}} |
| | 147 | |
| | 148 | Погледот е веќе најоптимално напишан со користење на постоечките уникатни констреинти и не бара дополнителни модификации. |
| 187 | | ||Gather (cost\=66949.49..416072.10 rows\=4 width\=145) (actual time\=667.628..676.676 rows\=0.00 loops\=1)|| |
| 188 | | || Workers Planned: 2|| |
| 189 | | || Workers Launched: 2|| |
| 190 | | || Buffers: shared read\=38603|| |
| 191 | | || -> Nested Loop Left Join (cost\=65949.49..415071.70 rows\=2 width\=145) (actual time\=612.744..612.748 rows\=0.00 loops\=3)|| |
| 192 | | || Buffers: shared read\=38603|| |
| 193 | | || -> Nested Loop Left Join (cost\=65949.07..415070.67 rows\=2 width\=145) (actual time\=612.743..612.747 rows\=0.00 loops\=3)|| |
| 194 | | || Buffers: shared read\=38603|| |
| 195 | | || -> Nested Loop (cost\=65948.64..415069.63 rows\=2 width\=129) (actual time\=612.742..612.746 rows\=0.00 loops\=3)|| |
| 196 | | || Buffers: shared read\=38603|| |
| 197 | | || -> Nested Loop (cost\=65948.35..415068.90 rows\=2 width\=98) (actual time\=612.742..612.745 rows\=0.00 loops\=3)|| |
| 198 | | || Buffers: shared read\=38603|| |
| 199 | | || -> Nested Loop (cost\=65948.07..415068.27 rows\=2 width\=90) (actual time\=612.741..612.745 rows\=0.00 loops\=3)|| |
| 200 | | || Buffers: shared read\=38603|| |
| 201 | | || -> Nested Loop (cost\=65947.63..415065.48 rows\=2 width\=82) (actual time\=612.741..612.744 rows\=0.00 loops\=3)|| |
| 202 | | || Buffers: shared read\=38603|| |
| 203 | | || -> Parallel Hash Join (cost\=65946.77..415052.55 rows\=2 width\=62) (actual time\=612.740..612.743 rows\=0.00 loops\=3)|| |
| 204 | | || Hash Cond: (toi.order_id \= o.order_id)|| |
| 205 | | || Buffers: shared read\=38603|| |
| 206 | | || -> Parallel Seq Scan on ""Ticket_Order_Item"" toi (cost\=0.00..326137.01 rows\=8750001 width\=62) (never executed)|| |
| 207 | | || -> Parallel Hash (cost\=65946.76..65946.76 rows\=1 width\=16) (actual time\=612.667..612.667 rows\=0.00 loops\=3)|| |
| 208 | | || Buckets: 1024 Batches: 1 Memory Usage: 0kB|| |
| 209 | | || Buffers: shared read\=38603|| |
| 210 | | || -> Parallel Seq Scan on ""Ticket_Order"" o (cost\=0.00..65946.76 rows\=1 width\=16) (actual time\=612.428..612.428 rows\=0.00 loops\=3)|| |
| 211 | | || Filter: (user_id \= 5)|| |
| 212 | | || Rows Removed by Filter: 1750000|| |
| 213 | | || Buffers: shared read\=38603|| |
| 214 | | || -> Materialize (cost\=0.86..12.91 rows\=1 width\=36) (never executed)|| |
| 215 | | || -> Nested Loop (cost\=0.86..12.90 rows\=1 width\=36) (never executed)|| |
| 216 | | || -> Index Scan using ""User_pkey"" on ""User"" u (cost\=0.43..8.45 rows\=1 width\=28) (never executed)|| |
| 217 | | || Index Cond: (user_id \= 5)|| |
| 218 | | || Index Searches: 0|| |
| 219 | | || -> Index Only Scan using ""Regular_User_pkey"" on ""Regular_User"" ru (cost\=0.43..4.45 rows\=1 width\=8) (never executed)|| |
| 220 | | || Index Cond: (user_id \= 5)|| |
| 221 | | || Heap Fetches: 0|| |
| 222 | | || Index Searches: 0|| |
| 223 | | || -> Index Scan using ""Ticket_pkey"" on ""Ticket"" t (cost\=0.44..1.39 rows\=1 width\=16) (never executed)|| |
| 224 | | || Index Cond: (ticket_id \= toi.ticket_id)|| |
| 225 | | || Index Searches: 0|| |
| 226 | | || -> Index Scan using ""Event_Happening_pkey"" on ""Event_Happening"" eh (cost\=0.29..0.31 rows\=1 width\=24) (never executed)|| |
| 227 | | || Index Cond: (event_happening_id \= t.event_happening_id)|| |
| 228 | | || Index Searches: 0|| |
| 229 | | || -> Index Scan using ""Event_pkey"" on ""Event"" e (cost\=0.29..0.37 rows\=1 width\=39) (never executed)|| |
| 230 | | || Index Cond: (event_id \= eh.event_id)|| |
| 231 | | || Index Searches: 0|| |
| 232 | | || -> Index Scan using ""Ticket_Refund_Item_order_item_id_key"" on ""Ticket_Refund_Item"" tri (cost\=0.43..0.52 rows\=1 width\=24) (never executed)|| |
| 233 | | || Index Cond: (order_item_id \= toi.order_item_id)|| |
| 234 | | || Index Searches: 0|| |
| 235 | | || -> Index Scan using ""Ticket_Refund_pkey"" on ""Ticket_Refund"" tr (cost\=0.42..0.52 rows\=1 width\=16) (never executed)|| |
| 236 | | || Index Cond: (refund_id \= tri.refund_id)|| |
| 237 | | || Index Searches: 0|| |
| 238 | | ||Planning:|| |
| 239 | | || Buffers: shared hit\=38 read\=57 dirtied\=3|| |
| 240 | | ||Planning Time: 29.035 ms|| |
| 241 | | ||Execution Time: 676.751 ms|| |
| | 180 | ||Gather (cost\=110699.49..459840.66 rows\=4 width\=145) (actual time\=370.701..375.993 rows\=0.00 loops\=1)|| |
| | 181 | ||Workers Planned: 2|| |
| | 182 | ||Workers Launched: 2|| |
| | 183 | ||Buffers: shared read\=82353|| |
| | 184 | ||-> Nested Loop Left Join (cost\=109699.49..458840.26 rows\=2 width\=145) (actual time\=312.925..312.929 rows\=0.00 loops\=3)|| |
| | 185 | ||Buffers: shared read\=82353|| |
| | 186 | ||-> Nested Loop Left Join (cost\=109699.07..458836.23 rows\=2 width\=145) (actual time\=312.924..312.928 rows\=0.00 loops\=3)|| |
| | 187 | ||Buffers: shared read\=82353|| |
| | 188 | ||-> Nested Loop (cost\=109698.64..458832.18 rows\=2 width\=129) (actual time\=312.923..312.927 rows\=0.00 loops\=3)|| |
| | 189 | ||Buffers: shared read\=82353|| |
| | 190 | ||-> Nested Loop (cost\=109698.35..458828.40 rows\=2 width\=98) (actual time\=312.923..312.927 rows\=0.00 loops\=3)|| |
| | 191 | ||Buffers: shared read\=82353|| |
| | 192 | ||-> Nested Loop (cost\=109698.07..458824.71 rows\=2 width\=90) (actual time\=312.923..312.926 rows\=0.00 loops\=3)|| |
| | 193 | ||Buffers: shared read\=82353|| |
| | 194 | ||-> Nested Loop (cost\=109697.63..458819.48 rows\=2 width\=82) (actual time\=312.922..312.925 rows\=0.00 loops\=3)|| |
| | 195 | ||Buffers: shared read\=82353|| |
| | 196 | ||-> Parallel Hash Join (cost\=109696.77..458802.55 rows\=2 width\=62) (actual time\=312.921..312.924 rows\=0.00 loops\=3)|| |
| | 197 | ||Hash Cond: (toi.order_id \= o.order_id)|| |
| | 198 | ||Buffers: shared read\=82353|| |
| | 199 | ||-> Parallel Seq Scan on ""Ticket_Order_Item"" toi (cost\=0.00..326137.01 rows\=8750001 width\=62) (never executed)|| |
| | 200 | ||-> Parallel Hash (cost\=109696.76..109696.76 rows\=1 width\=16) (actual time\=312.874..312.875 rows\=0.00 loops\=3)|| |
| | 201 | ||Buckets: 1024 Batches: 1 Memory Usage: 0kB|| |
| | 202 | ||Buffers: shared read\=82353|| |
| | 203 | ||-> Parallel Seq Scan on ""Ticket_Order"" o (cost\=0.00..109696.76 rows\=1 width\=16) (actual time\=312.664..312.664 rows\=0.00 loops\=3)|| |
| | 204 | ||Filter: (user_id \= 5)|| |
| | 205 | ||Rows Removed by Filter: 1750000|| |
| | 206 | ||Buffers: shared read\=82353|| |
| | 207 | ||-> Materialize (cost\=0.86..16.91 rows\=1 width\=36) (never executed)|| |
| | 208 | ||-> Nested Loop (cost\=0.86..16.91 rows\=1 width\=36) (never executed)|| |
| | 209 | ||-> Index Scan using ""User_pkey"" on ""User"" u (cost\=0.43..8.45 rows\=1 width\=28) (never executed)|| |
| | 210 | ||Index Cond: (user_id \= 5)|| |
| | 211 | ||Filter: is_active|| |
| | 212 | ||Index Searches: 0|| |
| | 213 | ||-> Index Only Scan using ""Regular_User_pkey"" on ""Regular_User"" ru (cost\=0.43..8.45 rows\=1 width\=8) (never executed)|| |
| | 214 | ||Index Cond: (user_id \= 5)|| |
| | 215 | ||Heap Fetches: 0|| |
| | 216 | ||Index Searches: 0|| |
| | 217 | ||-> Index Scan using ""Ticket_pkey"" on ""Ticket"" t (cost\=0.44..2.61 rows\=1 width\=16) (never executed)|| |
| | 218 | ||Index Cond: (ticket_id \= toi.ticket_id)|| |
| | 219 | ||Index Searches: 0|| |
| | 220 | ||-> Index Scan using ""Event_Happening_pkey"" on ""Event_Happening"" eh (cost\=0.29..1.85 rows\=1 width\=24) (never executed)|| |
| | 221 | ||Index Cond: (event_happening_id \= t.event_happening_id)|| |
| | 222 | ||Index Searches: 0|| |
| | 223 | ||-> Index Scan using ""Event_pkey"" on ""Event"" e (cost\=0.29..1.89 rows\=1 width\=39) (never executed)|| |
| | 224 | ||Index Cond: (event_id \= eh.event_id)|| |
| | 225 | ||Index Searches: 0|| |
| | 226 | ||-> Index Scan using ""Ticket_Refund_Item_order_item_id_key"" on ""Ticket_Refund_Item"" tri (cost\=0.43..2.02 rows\=1 width\=24) (never executed)|| |
| | 227 | ||Index Cond: (order_item_id \= toi.order_item_id)|| |
| | 228 | ||Index Searches: 0|| |
| | 229 | ||-> Index Scan using ""Ticket_Refund_pkey"" on ""Ticket_Refund"" tr (cost\=0.42..2.02 rows\=1 width\=16) (never executed)|| |
| | 230 | ||Index Cond: (refund_id \= tri.refund_id)|| |
| | 231 | ||Index Searches: 0|| |
| | 232 | ||Planning|| |
| | 233 | ||Buffers: shared hit\=33 read\=44 dirtied\=2|| |
| | 234 | ||Planning Time: 13.836 ms|| |
| | 235 | ||Execution Time: 376.133 ms|| |
| 323 | | ||Nested Loop Left Join (cost\=3.59..42.94 rows\=4 width\=145) (actual time\=0.070..0.073 rows\=0.00 loops\=1)|| |
| 324 | | || Buffers: shared hit\=11|| |
| 325 | | || -> Nested Loop Left Join (cost\=3.17..40.87 rows\=4 width\=145) (actual time\=0.070..0.072 rows\=0.00 loops\=1)|| |
| 326 | | || Buffers: shared hit\=11|| |
| 327 | | || -> Nested Loop (cost\=2.74..38.81 rows\=4 width\=129) (actual time\=0.070..0.071 rows\=0.00 loops\=1)|| |
| 328 | | || Buffers: shared hit\=11|| |
| 329 | | || -> Nested Loop (cost\=2.46..37.34 rows\=4 width\=98) (actual time\=0.069..0.071 rows\=0.00 loops\=1)|| |
| 330 | | || Buffers: shared hit\=11|| |
| 331 | | || -> Nested Loop (cost\=2.17..36.09 rows\=4 width\=90) (actual time\=0.069..0.071 rows\=0.00 loops\=1)|| |
| 332 | | || Buffers: shared hit\=11|| |
| 333 | | || -> Nested Loop (cost\=1.73..30.51 rows\=4 width\=82) (actual time\=0.069..0.070 rows\=0.00 loops\=1)|| |
| 334 | | || Buffers: shared hit\=11|| |
| 335 | | || -> Nested Loop (cost\=1.29..21.36 rows\=1 width\=36) (actual time\=0.069..0.069 rows\=0.00 loops\=1)|| |
| 336 | | || Buffers: shared hit\=11|| |
| 337 | | || -> Nested Loop (cost\=0.86..12.90 rows\=1 width\=36) (actual time\=0.039..0.041 rows\=1.00 loops\=1)|| |
| 338 | | || Buffers: shared hit\=8|| |
| 339 | | || -> Index Scan using ""User_pkey"" on ""User"" u (cost\=0.43..8.45 rows\=1 width\=28) (actual time\=0.017..0.018 rows\=1.00 loops\=1)|| |
| 340 | | || Index Cond: (user_id \= 99)|| |
| 341 | | || Index Searches: 1|| |
| 342 | | || Buffers: shared hit\=4|| |
| 343 | | || -> Index Only Scan using ""Regular_User_pkey"" on ""Regular_User"" ru (cost\=0.43..4.45 rows\=1 width\=8) (actual time\=0.018..0.019 rows\=1.00 loops\=1)|| |
| 344 | | || Index Cond: (user_id \= 99)|| |
| 345 | | || Heap Fetches: 0|| |
| 346 | | || Index Searches: 1|| |
| 347 | | || Buffers: shared hit\=4|| |
| 348 | | || -> Index Scan using idx_ticket_order_user_id on ""Ticket_Order"" o (cost\=0.43..8.44 rows\=1 width\=16) (actual time\=0.027..0.027 rows\=0.00 loops\=1)|| |
| 349 | | || Index Cond: (user_id \= 99)|| |
| 350 | | || Index Searches: 1|| |
| 351 | | || Buffers: shared hit\=3|| |
| 352 | | || -> Index Scan using idx_toi_order_id on ""Ticket_Order_Item"" toi (cost\=0.44..8.89 rows\=26 width\=62) (never executed)|| |
| 353 | | || Index Cond: (order_id \= o.order_id)|| |
| 354 | | || Index Searches: 0|| |
| 355 | | || -> Index Scan using ""Ticket_pkey"" on ""Ticket"" t (cost\=0.44..1.39 rows\=1 width\=16) (never executed)|| |
| 356 | | || Index Cond: (ticket_id \= toi.ticket_id)|| |
| 357 | | || Index Searches: 0|| |
| 358 | | || -> Index Scan using ""Event_Happening_pkey"" on ""Event_Happening"" eh (cost\=0.29..0.31 rows\=1 width\=24) (never executed)|| |
| 359 | | || Index Cond: (event_happening_id \= t.event_happening_id)|| |
| 360 | | || Index Searches: 0|| |
| 361 | | || -> Index Scan using ""Event_pkey"" on ""Event"" e (cost\=0.29..0.37 rows\=1 width\=39) (never executed)|| |
| 362 | | || Index Cond: (event_id \= eh.event_id)|| |
| 363 | | || Index Searches: 0|| |
| 364 | | || -> Index Scan using ""Ticket_Refund_Item_order_item_id_key"" on ""Ticket_Refund_Item"" tri (cost\=0.43..0.52 rows\=1 width\=24) (never executed)|| |
| 365 | | || Index Cond: (order_item_id \= toi.order_item_id)|| |
| 366 | | || Index Searches: 0|| |
| 367 | | || -> Index Scan using ""Ticket_Refund_pkey"" on ""Ticket_Refund"" tr (cost\=0.42..0.52 rows\=1 width\=16) (never executed)|| |
| 368 | | || Index Cond: (refund_id \= tri.refund_id)|| |
| 369 | | || Index Searches: 0|| |
| 370 | | ||Planning:|| |
| 371 | | || Buffers: shared hit\=295 read\=8|| |
| 372 | | ||Planning Time: 74.096 ms|| |
| 373 | | ||Execution Time: 0.196 ms|| |
| | 319 | ||Nested Loop Left Join (cost\=3.59..75.95 rows\=4 width\=145) (actual time\=1.244..1.247 rows\=0.00 loops\=1)|| |
| | 320 | ||Buffers: shared hit\=1 read\=10|| |
| | 321 | ||-> Nested Loop Left Join (cost\=3.17..67.89 rows\=4 width\=145) (actual time\=1.243..1.246 rows\=0.00 loops\=1)|| |
| | 322 | ||Buffers: shared hit\=1 read\=10|| |
| | 323 | ||-> Nested Loop (cost\=2.74..59.80 rows\=4 width\=129) (actual time\=1.242..1.245 rows\=0.00 loops\=1)|| |
| | 324 | ||Buffers: shared hit\=1 read\=10|| |
| | 325 | ||-> Nested Loop (cost\=2.46..52.24 rows\=4 width\=98) (actual time\=1.242..1.244 rows\=0.00 loops\=1)|| |
| | 326 | ||Buffers: shared hit\=1 read\=10|| |
| | 327 | ||-> Nested Loop (cost\=2.17..44.84 rows\=4 width\=90) (actual time\=1.241..1.244 rows\=0.00 loops\=1)|| |
| | 328 | ||Buffers: shared hit\=1 read\=10|| |
| | 329 | ||-> Nested Loop (cost\=1.73..34.40 rows\=4 width\=82) (actual time\=1.241..1.243 rows\=0.00 loops\=1)|| |
| | 330 | ||Buffers: shared hit\=1 read\=10|| |
| | 331 | ||-> Nested Loop (cost\=1.29..25.36 rows\=1 width\=36) (actual time\=1.240..1.242 rows\=0.00 loops\=1)|| |
| | 332 | ||Buffers: shared hit\=1 read\=10|| |
| | 333 | ||-> Nested Loop (cost\=0.86..16.91 rows\=1 width\=36) (actual time\=1.119..1.123 rows\=1.00 loops\=1)|| |
| | 334 | ||Buffers: shared hit\=1 read\=7|| |
| | 335 | ||-> Index Scan using ""User_pkey"" on ""User"" u (cost\=0.43..8.45 rows\=1 width\=28) (actual time\=0.716..0.718 rows\=1.00 loops\=1)|| |
| | 336 | ||Index Cond: (user_id \= 99)|| |
| | 337 | ||Filter: is_active|| |
| | 338 | ||Index Searches: 1|| |
| | 339 | ||Buffers: shared read\=4|| |
| | 340 | ||-> Index Only Scan using ""Regular_User_pkey"" on ""Regular_User"" ru (cost\=0.43..8.45 rows\=1 width\=8) (actual time\=0.398..0.400 rows\=1.00 loops\=1)|| |
| | 341 | ||Index Cond: (user_id \= 99)|| |
| | 342 | ||Heap Fetches: 0|| |
| | 343 | ||Index Searches: 1|| |
| | 344 | ||Buffers: shared hit\=1 read\=3|| |
| | 345 | ||-> Index Scan using idx_ticket_order_user_id on ""Ticket_Order"" o (cost\=0.43..8.44 rows\=1 width\=16) (actual time\=0.116..0.116 rows\=0.00 loops\=1)|| |
| | 346 | ||Index Cond: (user_id \= 99)|| |
| | 347 | ||Index Searches: 1|| |
| | 348 | ||Buffers: shared read\=3|| |
| | 349 | ||-> Index Scan using idx_toi_order_id on ""Ticket_Order_Item"" toi (cost\=0.44..8.82 rows\=22 width\=62) (never executed)|| |
| | 350 | ||Index Cond: (order_id \= o.order_id)|| |
| | 351 | ||Index Searches: 0|| |
| | 352 | ||-> Index Scan using ""Ticket_pkey"" on ""Ticket"" t (cost\=0.44..2.61 rows\=1 width\=16) (never executed)|| |
| | 353 | ||Index Cond: (ticket_id \= toi.ticket_id)|| |
| | 354 | ||Index Searches: 0|| |
| | 355 | ||-> Index Scan using ""Event_Happening_pkey"" on ""Event_Happening"" eh (cost\=0.29..1.85 rows\=1 width\=24) (never executed)|| |
| | 356 | ||Index Cond: (event_happening_id \= t.event_happening_id)|| |
| | 357 | ||Index Searches: 0|| |
| | 358 | ||-> Index Scan using ""Event_pkey"" on ""Event"" e (cost\=0.29..1.89 rows\=1 width\=39) (never executed)|| |
| | 359 | ||Index Cond: (event_id \= eh.event_id)|| |
| | 360 | ||Index Searches: 0|| |
| | 361 | ||-> Index Scan using ""Ticket_Refund_Item_order_item_id_key"" on ""Ticket_Refund_Item"" tri (cost\=0.43..2.02 rows\=1 width\=24) (never executed)|| |
| | 362 | ||Index Cond: (order_item_id \= toi.order_item_id)|| |
| | 363 | ||Index Searches: 0|| |
| | 364 | ||-> Index Scan using ""Ticket_Refund_pkey"" on ""Ticket_Refund"" tr (cost\=0.42..2.02 rows\=1 width\=16) (never executed)|| |
| | 365 | ||Index Cond: (refund_id \= tri.refund_id)|| |
| | 366 | ||Index Searches: 0|| |
| | 367 | ||Planning|| |
| | 368 | ||Buffers: shared hit\=264 read\=37|| |
| | 369 | ||Planning Time: 41.864 ms|| |
| | 370 | ||Execution Time: 1.392 ms|| |