Update statistics when reindexing a functional index
The reindexing feature creates a new index, swaps it with the original one and drops the original index afterwards.
This has led to gitlab-com/gl-infra/production#2885 (closed), which was caused by missing statistics for a functional index.
For functional indexes, the reindexing feature needs to update statistics through ANALYZE $table
after creating the new index.
We might also want to add an assertion to check that statistics are present before dropping the old index:
select count(*) from pg_statistic where starelid = (select oid from pg_class where relname = 'index_name');