282 | | |
283 | | == Тест |
284 | | |
285 | | Во табелата test_instance се додаваат 5.000.000 тест записи со вредност за scheduled_for во ранг од 2022 до 2025 година. Истите квериња се извршени на партиционирана табела и на непартиционирана табела. |
286 | | |
287 | | 1. Прво квери: |
288 | | |
289 | | {{{#!div |
290 | | {{{#!sql |
291 | | explain (analyse, buffers) |
292 | | select * from test_instance where scheduled_for between '2024-01-01' and '2024-03-01'; |
293 | | }}} |
294 | | }}} |
295 | | |
296 | | 2. Второ квери |
297 | | |
298 | | {{{#!div |
299 | | {{{#!sql |
300 | | explain (analyse, buffers) |
301 | | select * from test_instance where scheduled_for between '2024-01-01' and '2024-03-01' and scheduled_until between '2024-01-01' and '2024-10-01'; |
302 | | }}} |
303 | | }}} |
304 | | |
305 | | 3. |
306 | | |
307 | | {{{#!div |
308 | | {{{#!sql |
309 | | explain (analyse, buffers) |
310 | | select * |
311 | | from test_instance |
312 | | where scheduled_for between '2024-01-01' and '2025-01-01'; |
313 | | }}} |
314 | | }}} |
315 | | |
316 | | === Без партиционирање |
317 | | |
318 | | |
319 | | |
320 | | === Со партиционирање |
321 | | |
322 | | {{{#!div |
323 | | {{{#!sql |
324 | | Seq Scan on test_instance_2023_2024 test_instance (cost=0.00..35022.53 rows=168312 width=112) (actual time=0.075..313.242 rows=167605 loops=1) |
325 | | Filter: ((scheduled_for >= '2024-01-01 00:00:00'::timestamp without time zone) AND (scheduled_for <= '2024-03-01 00:00:00'::timestamp without time zone)) |
326 | | Rows Removed by Filter: 855497 |
327 | | Buffers: shared hit=3186 read=16490 |
328 | | Planning Time: 0.103 ms |
329 | | Execution Time: 533.276 ms |
330 | | }}} |
331 | | }}} |
332 | | |
333 | | |
334 | | {{{#!div |
335 | | {{{#!sql |
336 | | Gather (cost=1000.00..31034.15 rows=18323 width=112) (actual time=9.510..73.809 rows=18628 loops=1) |
337 | | Workers Planned: 2 |
338 | | Workers Launched: 2 |
339 | | Buffers: shared hit=3218 read=16458 |
340 | | -> Parallel Seq Scan on test_instance_2023_2024 test_instance (cost=0.00..28201.85 rows=7635 width=112) (actual time=7.168..45.342 rows=6209 loops=3) |
341 | | Filter: ((scheduled_for >= '2024-01-01 00:00:00'::timestamp without time zone) AND (scheduled_for <= '2024-03-01 00:00:00'::timestamp without time zone) AND (scheduled_until >= '2024-01-01 00:00:00'::timestamp without time zone) AND (scheduled_until <= '2024-10-01 00:00:00'::timestamp without time zone)) |
342 | | Rows Removed by Filter: 334825 |
343 | | Buffers: shared hit=3218 read=16458 |
344 | | Planning Time: 0.111 ms |
345 | | Execution Time: 99.826 ms |
346 | | }}} |
347 | | }}} |
348 | | |
349 | | {{{#!div |
350 | | {{{#!sql |
351 | | Append (cost=0.00..63966.17 rows=1024027 width=112) (actual time=0.042..4192.731 rows=1023818 loops=1) |
352 | | Buffers: shared hit=5077 read=27983 |
353 | | -> Seq Scan on test_instance_2023_2024 test_instance_1 (cost=0.00..35022.53 rows=766644 width=112) (actual time=0.039..1100.165 rows=766431 loops=1) |
354 | | Filter: ((scheduled_for >= '2024-01-01 00:00:00'::timestamp without time zone) AND (scheduled_for <= '2025-01-01 00:00:00'::timestamp without time zone)) |
355 | | Rows Removed by Filter: 256671 |
356 | | Buffers: shared hit=3154 read=16522 |
357 | | -> Seq Scan on test_instance_2024_2025 test_instance_2 (cost=0.00..23823.50 rows=257383 width=112) (actual time=0.019..430.753 rows=257387 loops=1) |
358 | | Filter: ((scheduled_for >= '2024-01-01 00:00:00'::timestamp without time zone) AND (scheduled_for <= '2025-01-01 00:00:00'::timestamp without time zone)) |
359 | | Rows Removed by Filter: 438580 |
360 | | Buffers: shared hit=1923 read=11461 |
361 | | Planning Time: 0.144 ms |
362 | | Execution Time: 5525.093 ms |
363 | | }}} |
364 | | }}} |