Add indices to stats temporary tables

Since we're doing many queries to get stats for each age group and each
geozone, testing shows these indices make stats calculation about 25%
faster on processes with 100,000 participants.
This commit is contained in:
Javi Martín
2024-04-09 15:53:57 +02:00
parent 80dcbfc23c
commit 62cd4c8d7b

View File

@@ -174,6 +174,8 @@ module Statisticable
temporary: true,
as: participants_from_original_table.to_sql
)
User.connection.add_index participants_table_name, :date_of_birth
User.connection.add_index participants_table_name, :geozone_id
end
def drop_participants_table