Create index on security_findings for LATERAL finder query

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

To further improve on the performance changes to Security::FindingsFinder implemented in !132191 (merged) we can add a new index:

CREATE INDEX ON security_findings (scan_id, deduplicated, severity DESC, id ASC)

Before adding index

https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/22950/commands/73996

Time: 58.859 ms
  - planning: 33.002 ms
  - execution: 25.857 ms
    - I/O read: 0.000 ms
    - I/O write: 0.000 ms

Shared buffers:
  - hits: 9163 (~71.60 MiB) from the buffer pool
  - reads: 0 from the OS file cache, including disk I/O
  - dirtied: 0
  - writes: 0

After adding index

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/22950/commands/74042

Time: 39.496 ms
  - planning: 36.672 ms
  - execution: 2.824 ms
    - I/O read: 0.000 ms
    - I/O write: 0.000 ms

Shared buffers:
  - hits: 1111 (~8.70 MiB) from the buffer pool
  - reads: 0 from the OS file cache, including disk I/O
  - dirtied: 0
  - writes: 0
Edited by 🤖 GitLab Bot 🤖