Skip to content

Switch to using an EXISTS query

mo khan requested to merge mokhax/29/count-query into master

What does this MR do and why?

Before:

SELECT
    "security_findings".*
FROM
    "security_findings"
    INNER JOIN "security_scans" ON "security_findings"."scan_id" = "security_scans"."id"
WHERE
    "security_scans"."pipeline_id" = 832983315
LIMIT 1
  • Current: hits: 65 (~520.00 KiB) from the buffer pool

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/17711/commands/59142

After:

SELECT 1 AS one 
FROM "security_findings" 
INNER JOIN "security_scans" ON "security_findings"."scan_id" = "security_scans"."id" 
WHERE "security_scans"."pipeline_id" = 600 AND (finding_data <> '{}') 
LIMIT 1;
  • EXISTS: hits: 7 (~56.00 KiB) from the buffer pool

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/17725/commands/59158

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 mo khan

Merge request reports

Loading