sql: add indexes on receipt_time and anonymised columns (#33707)
This commit is contained in:
parent
1fdb67feb4
commit
d0afa819bf
10
wcs/sql.py
10
wcs/sql.py
|
@ -577,6 +577,13 @@ def do_formdef_indexes(formdef, created, conn, cur, concurrently=False):
|
|||
cur.execute('''%s %s_fid ON %s (formdata_id)''' % (
|
||||
create_index, evolutions_table_name, evolutions_table_name))
|
||||
|
||||
for attr in ('receipt_time', 'anonymised'):
|
||||
if not table_name + '_' + attr + '_idx' in existing_indexes:
|
||||
cur.execute('%(create_index)s %(table_name)s_%(attr)s ON %(table_name)s (%(attr)s)' % {
|
||||
'create_index': create_index,
|
||||
'table_name': table_name,
|
||||
'attr': attr})
|
||||
|
||||
@guard_postgres
|
||||
def do_user_table():
|
||||
conn, cur = get_connection_and_cursor()
|
||||
|
@ -2249,7 +2256,7 @@ def get_yearly_totals(period_start=None, period_end=None, criterias=None):
|
|||
return result
|
||||
|
||||
|
||||
SQL_LEVEL = 33
|
||||
SQL_LEVEL = 34
|
||||
|
||||
def migrate_global_views(conn, cur):
|
||||
cur.execute('''SELECT COUNT(*) FROM information_schema.tables
|
||||
|
@ -2366,6 +2373,7 @@ def migrate():
|
|||
if sql_level < 24:
|
||||
from wcs.formdef import FormDef
|
||||
# 24: add index on evolution(formdata_id)
|
||||
# 34: add indexes on formdata(receipt_time) and formdata(anonymised)
|
||||
for formdef in FormDef.select():
|
||||
do_formdef_indexes(formdef, created=False, conn=conn, cur=cur)
|
||||
if sql_level < 32:
|
||||
|
|
Loading…
Reference in New Issue