Productivity analytics post-deploy causes statement timeouts in staging
The post-deploy from !15137 (comment 218016968) has a query that causes a statement timeout (at 10s) in staging. It requires an index to be sped up:
SELECT "merge_request_metrics"."id" FROM "merge_request_metrics" WHERE (merged_at >= '2019-06-17 21:35:13.413266') ORDER BY "merge_request_metrics"."id" ASC LIMIT 1
- Plan staging (11s): https://explain.depesz.com/s/7epE
- Plan production (0.15s): https://explain.depesz.com/s/LFBO
The reason the timings are faster in production need more investigation. Upon a quick look: A lot more data is scanned and discarded in staging, yet to be detailed why that is.
Still, the plan should be optimized.
Edited by Andreas Brandl