Changes between Version 3 and Version 4 of OtherDevelopments
- Timestamp:
- 06/04/26 22:05:07 (11 days ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
OtherDevelopments
v3 v4 90 90 The index on enroll_date improves the yearly grouping operation because the report groups data by year. 91 91 92 Result without indexes: 93 94 {{{ 95 Seq Scan on quiz_attempt qa_1 96 Seq Scan on quiz q_1 97 Seq Scan on lesson l_1 98 Seq Scan on module m_1 99 Seq Scan on course c_1 100 101 Planning Time: 3.565 ms 102 Execution Time: 202.790 ms 103 }}} 104 105 # Before adding indexes, PostgreSQL used sequential scans on the main joined tables, especially on quiz_attempt, which contains 20000 test records. The query execution time was 202.790 ms. 106 107 Result with indexes: 108 109 {{{ 110 Seq Scan on quiz_attempt qa_1 111 Seq Scan on quiz q_1 112 Seq Scan on lesson l_1 113 Seq Scan on module m_1 114 Seq Scan on course c_1 115 116 Planning Time: 8.008 ms 117 Execution Time: 218.476 ms 118 }}} 119 120 # After adding indexes, PostgreSQL still selected sequential scans for the main tables. This happened because the query aggregates almost all quiz_attempt records, so reading the whole table was cheaper than using indexes. The execution time increased slightly from 202.790 ms to 218.476 ms; these indexes did not improve this specific analytical query. 121 92 122 === Scenario 2: Monthly Analysis of Course Activity, Completions, Instructor Involvement and Student Success === 93 123 … … 160 190 161 191 These indexes reduce the amount of data PostgreSQL needs to scan when generating monthly reports. 192 193 Result without indexes: 194 195 {{{ 196 Seq Scan on enrollment e 197 Seq Scan on course c 198 Hash Join 199 Merge Left Join 200 Sort 201 HashAggregate 202 203 Planning Time: 5.537 ms 204 Execution Time: 87.215 ms 205 }}} 206 207 Result њith indexes: 208 209 {{{ 210 Seq Scan on enrollment e 211 Seq Scan on course c 212 Hash Join 213 Merge Left Join 214 Sort 215 HashAggregate 216 217 Planning Time: 6.799 ms 218 Execution Time: 111.731 ms 219 }}} 220 221 # After adding indexes, PostgreSQL still selected sequential scans for the main tables. The query performs monthly aggregation over most of the enrollment and quiz_attempt records, so the planner estimated that sequential scanning was cheaper than using indexes. The execution time increased from 87.215 ms to 111.731 ms, therefore these indexes did not improve this specific analytical query. 162 222 163 223 = Security and Protection Measures =
