Skip to content

[*] repurpose duplicate_count in DROP INDEX recommendations#1446

Merged
pashagolub merged 2 commits into
masterfrom
adjust-reco-drop=index-metric
Jun 19, 2026
Merged

[*] repurpose duplicate_count in DROP INDEX recommendations#1446
pashagolub merged 2 commits into
masterfrom
adjust-reco-drop=index-metric

Conversation

@avandras

Copy link
Copy Markdown
Contributor

Description

The current query has a usecase-specific column, which semantically doesn't feel right (the usecase is a value like 'duplicate' or 'invalid' whereas the column name is duplicate_count. Also, with the proposed change a query which has looked like

WITH q_invalid AS (
  SELECT count(*) as cnt
    FROM recommendations
   WHERE time = (SELECT max(time) 
                   FROM recommendations 
                  WHERE $__timeFilter(time)
                    AND dbname = '$dbname' 
                    AND tag_data->>'reco_topic' = 'drop_index' 
                    AND tag_data->>'issue_type' = 'invalid'
                )
  AND dbname = '$dbname' AND tag_data->>'reco_topic' = 'drop_index' AND tag_data->>'issue_type' = 'invalid'
)
SELECT sum((data->>'duplicate_count')::int8) + (select cnt from q_invalid)::int8
  FROM recommendations
 WHERE time = (
               select max(time)
                 from recommendations
                where $__timeFilter(time)
                  AND dbname = '$dbname' 
                  AND tag_data->>'reco_topic' = 'drop_index' 
                  AND tag_data->>'issue_type' = 'duplicate'
              )
  AND dbname = '$dbname' AND tag_data->>'reco_topic' = 'drop_index' AND tag_data->>'issue_type' = 'duplicate'

would turn into the arguably easier to understand

WITH collection_time AS (
    SELECT max(time) AS max_time
      FROM recommendations 
     WHERE $__timeFilter(time)
       AND dbname = '$dbname' 
       AND tag_data->>'reco_topic' = 'drop_index'
)
SELECT sum((data->>'affected_count')
  FROM recommendations 
  JOIN collection_time ON time = max_time
 WHERE dbname = '$dbname' 
   AND tag_data->>'reco_topic' = 'drop_index'
   AND tag_data->>'issue_type' IN ('duplicate', 'invalid')

AI & Automation Policy

  • I am the human author and take full personal responsibility for every change in this PR.
  • No AI or automated generative tool was used in any part of this PR OR I have disclosed all tool(s) below.

AI/automation tools used (leave blank if none):

Checklist

  • Code compiles and existing tests pass locally.
  • New or updated tests are included where applicable.
  • Documentation is updated where applicable.

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 27702759741

Coverage increased (+0.1%) to 85.966%

Details

  • Coverage increased (+0.1%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 5451
Covered Lines: 4686
Line Coverage: 85.97%
Coverage Strength: 0.98 hits per line

💛 - Coveralls

@avandras avandras requested review from 0xgouda and pashagolub June 19, 2026 07:30
@pashagolub pashagolub self-assigned this Jun 19, 2026
@pashagolub pashagolub added the dashboards Grafana dashboards related label Jun 19, 2026
@pashagolub pashagolub changed the title Repurpose duplicate_count field in DROP INDEX recommendations [*] repurpose duplicate_count in DROP INDEX recommendations Jun 19, 2026
@pashagolub pashagolub merged commit 08b9c8f into master Jun 19, 2026
12 of 14 checks passed
@pashagolub pashagolub deleted the adjust-reco-drop=index-metric branch June 19, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dashboards Grafana dashboards related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants