Skip to content

Optimize projects_with_prometheus_alerts query

What does this MR do?

Optimizes the projects_with_prometheus_alerts counter query for batch counting in usage data

Part of issue #208923 (closed)

Query

SELECT COUNT(DISTINCT prometheus_alerts.project_id) FROM prometheus_alerts WHERE prometheus_alerts.project_id BETWEEN 0 AND 9999;

Optimization

No optimization needed, see: https://explain.depesz.com/s/W6NE

Timing

Time: 0.315 ms

  • planning: 0.151 ms
  • execution: 0.164 ms
    • I/O read: 0.000 ms
    • I/O write: 0.000 ms

Shared buffers:

  • hits: 6 (~48.00 KiB) from the buffer pool
  • reads: 0 from the OS file cache, including disk I/O
  • dirtied: 0
  • writes: 0
Edited by Alex Buijs

Merge request reports