Refactor issues with embedded grafana charts
Refactor issues_with_embedded_grafana_charts_approx to use the batch counting with failover fallback
- Move the issues_with_embedded_grafana_charts_approx to batch counting
- Move the files into usage_data.rb
- Move the specs
Issue #213126 (closed)
Queries
SELECT MIN("issues"."id") FROM "issues" JOIN grafana_integrations USING (project_id) WHERE (issues.description LIKE '%' || grafana_integrations.grafana_url || '%') AND "grafana_integrations"."enabled" = TRUE
SELECT MAX("issues"."id") FROM "issues" JOIN grafana_integrations USING (project_id) WHERE (issues.description LIKE '%' || grafana_integrations.grafana_url || '%') AND "grafana_integrations"."enabled" = TRUE
SELECT COUNT("issues"."id") FROM "issues" JOIN grafana_integrations USING (project_id) WHERE (issues.description LIKE '%' || grafana_integrations.grafana_url || '%') AND "grafana_integrations"."enabled" = TRUE AND "issues"."id" BETWEEN 0 AND 99999
Optimization is not needed
gprd ] production> [Time.now, Gitlab::UsageData.count(Issue.joins('JOIN grafana_integrations USING (project_id)').where("issues.description LIKE '%' || grafana_integrations.grafana_url || '%'").where(grafana_integrations: { enabled: true })), Time.now]
=> [2020-04-06 20:12:02 +0000, 241, 2020-04-06 20:12:30 +0000]
# It takes 28 seconds to with batch counter, to count the data
[
Query | Before |
---|---|
MIN | https://explain.depesz.com/s/5Ms2 |
MAX | https://explain.depesz.com/s/bNF1 |
RANGE | https://explain.depesz.com/s/pHq |
Edited by Alper Akgun