Skip to content

Resolve "ActiveRecord::QueryCanceled: PG::QueryCanceled: ERROR: canceling statement due to statement timeout"

What does this MR do and why?

Related to #371703 (closed)

This change originates from the work in !93633 (merged).

We have to apply a force SELECT(*) before the pagination logic kicks in. More details are added as comments in the diff.

Query performance

Performance of the COUNT query originating from Kaminari:

Before: https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/12163/commands/43164 - 18.5 minutes!

After: https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/12163/commands/43163 - ~686 ms.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Manoj M J

Merge request reports