Changes between Version 10 and Version 11 of F3
- Timestamp:
- 05/27/26 19:56:47 (9 hours ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
F3
v10 v11 11 11 }}} 12 12 13 [[Image(filter.png)]] 13 {{{ 14 QUERY PLAN 15 Merge Right Join (cost=249312.60..251333.27 rows=980 width=20) (actual time=487.591..492.755 rows=49 loops=1) 16 Merge Cond: (ap.appointment_time = ts.slot_time) 17 -> Sort (cost=249234.46..250242.10 rows=403054 width=12) (actual time=487.433..492.584 rows=0 loops=1) 18 Sort Key: ap.appointment_time 19 Sort Method: quicksort Memory: 25kB 20 -> Gather (cost=1000.00..204817.40 rows=403054 width=12) (actual time=487.420..492.570 rows=0 loops=1) 21 Workers Planned: 2 22 Workers Launched: 2 23 -> Parallel Seq Scan on appointment ap (cost=0.00..163512.00 rows=167939 width=12) (actual time=458.175..458.175 rows=0 loops=3) 24 Filter: ((exam_room_id = 1) AND (status)::text = 'Scheduled'::text) 25 Rows Removed by Filter: 333333 26 -> Sort (cost=78.13..80.63 rows=1000 width=20) (actual time=0.155..0.159 rows=49 loops=1) 27 Sort Key: ts.slot_time 28 Sort Method: quicksort Memory: 26kB 29 -> Nested Loop (cost=0.29..28.30 rows=1000 width=20) (actual time=0.052..0.060 rows=49 loops=1) 30 -> Index Scan using exam_room_pkey on exam_room er (cost=0.28..8.29 rows=1 width=12) (actual time=0.019..0.020 rows=1 loops=1) 31 Index Cond: (exam_room_id = 1) 32 Filter: is_available 33 -> Function Scan on generate_series ts (cost=0.01..10.01 rows=1000 width=8) (actual time=0.026..0.029 rows=49 loops=1) 34 35 Planning Time: 1.971 ms 36 Execution Time: 492.828 ms 37 }}} 14 38 15 39 • Времето на извршување на insert изнесува 40.213ms. Тоа време е задоволително. 16 40 17 ```EXPLAIN ANALYZE``` 18 ```INSERT INTO Appointment (appointment_id, appointment-time, status, exam_room_id) VALUES (10000001, NOW() + INTERVAL '2 hours', 'Scheduled', 1);``` 41 {{{EXPLAIN ANALYZE}}} 42 {{{INSERT INTO Appointment (appointment_id, appointment-time, status, exam_room_id) VALUES (10000001, NOW() + INTERVAL '2 hours', 'Scheduled', 1);}}} 19 43 20 [[Image(insert.png)]] 44 {{{ 45 QUERY PLAN 46 47 Insert on appointment (cost=0.00..0.02 rows=0 width=0) (actual time=28.065..28.066 rows=0 loops=1) 48 -> Result (cost=0.00..0.02 rows=1 width=500) (actual time=0.007..0.007 rows=1 loops=1) 49 50 Planning Time: 0.053 ms 51 52 Trigger for constraint appointment_pet_id_fkey: time=11.548 calls=1 53 Trigger for constraint appointment_exam_room_id_fkey: time=0.487 calls=1 54 Trigger for constraint appointment_receptionist_id_fkey: time=0.080 calls=1 55 56 Execution Time: 40.213 ms 57 }}} 21 58 22 59 • Времето на извршување на update изнесува 2137.049ms. Тоа време можеме да го подобриме со индекс, бидејќи овој view би бил користен повеќе пати на ден при закажување нови прегледи. 23 60 24 ```EXPLAIN ANALYZE```25 ```UPDATE Appointment SET appointment_time = appointment_time + INTERVAL '30 minutes' WHERE exam_room_id = 1 AND status = 'Scheduled';``` 61 {{{EXPLAIN ANALYZE}}} 62 {{{UPDATE Appointment SET appointment_time = appointment_time + INTERVAL '30 minutes' WHERE exam_room_id = 1 AND status = 'Scheduled';}}} 26 63 27 [[Image(update1.png)]] 64 {{{ 65 QUERY PLAN 28 66 67 Update on appointment (cost=0.00..252019.64 rows=0 width=0) (actual time=2136.984..2136.986 rows=0 loops=1) 68 -> Seq Scan on appointment (cost=0.00..252019.64 rows=403054 width=14) (actual time=1938.264..1938.264 rows=0 loops=1) 69 Filter: ((exam_room_id = 1) AND ((status)::text = 'Scheduled'::text)) 70 Rows Removed by Filter: 10000000 71 72 Planning Time: 0.090 ms 73 74 Execution Time: 2137.049 ms 75 }}} 29 76 == Креирање на индексот == 30 77 31 CREATE INDEX idx_appointment_room_time ON Appointment (exam_room_id, status, appointment_time); 78 {{{CREATE INDEX idx_appointment_room_time ON Appointment (exam_room_id, status, appointment_time);}}} 32 79 33 80 == Подобрување на операцијата update по креирање на индекс == 34 81 35 [[Image(update2.png)]] 82 {{{ 83 QUERY PLAN 84 85 Update on appointment (cost=12127.90..217451.72 rows=0 width=0) (actual time=0.196..0.197 rows=0 loops=1) 86 -> Bitmap Heap Scan on appointment (cost=12127.90..217451.72 rows=403058 width=14) (actual time=0.053..0.059 rows=2 loops=1) 87 Recheck Cond: ((exam_room_id = 1) AND ((status)::text = 'Scheduled'::text)) 88 Heap Blocks: exact=2 89 -> Bitmap Index Scan on idx_appointment_room_time (cost=0.00..12027.14 rows=403058 width=0) (actual time=0.039..0.039 rows=2 loops=1) 90 Index Cond: ((exam_room_id = 1) AND ((status)::text = 'Scheduled'::text)) 91 92 Planning Time: 0.110 ms 93 94 Execution Time: 0.244 ms 95 }}} 36 96 37 97 == Останати погледи ==
