Investigate and improve query 3688023587103815744 for LWLock acquisition reduction
Investigate query ID `3688023587103815744` as part of https://gitlab.com/gitlab-com/gl-infra/production-engineering/-/work_items/28600.
### Details
(Refs: https://gitlab.com/gitlab-com/gl-infra/production-engineering/-/work_items/28600#note_3285345014, https://gitlab.com/gitlab-com/gl-infra/production-engineering/-/work_items/28600#note_3288785483)
- Call location: https://gitlab.com/gitlab-org/gitlab/-/blob/fefa87e975d663ed44a7cb96a56f89601e9d7070/app/models/ci/pipeline.rb#L1042-1047
- avg_call_rate: `898.909`
- locks_slowpath: `38`
- locks_fastpath: `16`
<details>
<summary>Normalized query text</summary>
```sql
SELECT $1 AS one FROM "p_ci_builds" WHERE "p_ci_builds"."commit_id" = $2 AND "p_ci_builds"."partition_id" = $3 AND ("p_ci_builds"."processed" = $4 OR "p_ci_builds"."processed" IS NULL) AND ("p_ci_builds"."retried" = $5 OR "p_ci_builds"."retried" IS NULL) LIMIT $6
```
</details>
## Proposal
Investigate whether this query can be improved with partition pruning or other strategies to reduce LWLock acquisition overhead, and apply the identified improvements if they are safe and effective.
Suggested work:
- Confirm the current execution path and query frequency.
- Verify whether partition pruning is already applied.
- If pruning is already present, evaluate alternative strategies such as query reshaping, index changes, cache/read-path changes, or moving read load to a replica.
- Apply the selected improvement.
- Document findings and estimated or observed impact on LWLock acquisition rate.
issue