sql: add index on user_id (#38902)
This commit is contained in:
parent
7faa7f9281
commit
f07937dfc3
|
@ -580,7 +580,7 @@ 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'):
|
||||
for attr in ('receipt_time', 'anonymised', 'user_id'):
|
||||
if not table_name + '_' + attr + '_idx' in existing_indexes:
|
||||
cur.execute('%(create_index)s %(table_name)s_%(attr)s_idx ON %(table_name)s (%(attr)s)' % {
|
||||
'create_index': create_index,
|
||||
|
@ -2292,7 +2292,7 @@ def get_yearly_totals(period_start=None, period_end=None, criterias=None):
|
|||
return result
|
||||
|
||||
|
||||
SQL_LEVEL = 35
|
||||
SQL_LEVEL = 36
|
||||
|
||||
def migrate_global_views(conn, cur):
|
||||
cur.execute('''SELECT COUNT(*) FROM information_schema.tables
|
||||
|
@ -2406,10 +2406,11 @@ def migrate():
|
|||
# 29: add evolution parts to full-text index
|
||||
# 31: add user_label to formdata
|
||||
set_reindex('formdata', 'needed', conn=conn, cur=cur)
|
||||
if sql_level < 35:
|
||||
if sql_level < 36:
|
||||
from wcs.formdef import FormDef
|
||||
# 24: add index on evolution(formdata_id)
|
||||
# 35: add indexes on formdata(receipt_time) and formdata(anonymised)
|
||||
# 36: add index on formdata(user_id)
|
||||
for formdef in FormDef.select():
|
||||
do_formdef_indexes(formdef, created=False, conn=conn, cur=cur)
|
||||
if sql_level < 32:
|
||||
|
|
Loading…
Reference in New Issue