Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: fix aggregation of statistics #85987

Merged
merged 1 commit into from
Aug 12, 2022
Merged

Conversation

maryliag
Copy link
Contributor

Previously, because we were using a join, we were double
counting statistics when we had the same fingerprint in
memory and persisted.
This commit adds a DISTINCT so we only count them once.

Fixes #85958

Release note: None

@maryliag maryliag requested review from a team and removed request for a team August 11, 2022 19:15
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@xinhaoz
Copy link
Member

xinhaoz commented Aug 11, 2022

pkg/sql/logictest/testdata/logic_test/create_statements line 1574 at r1 (raw file):

    app_name,
    max(metadata) AS metadata,
    crdb_internal.merge_statement_stats(array_agg(DISTINCT statistics)),

Maybe we can add a logic test with the case you saw in the issue or similar

Copy link
Contributor Author

@maryliag maryliag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @xinhaoz)


pkg/sql/logictest/testdata/logic_test/create_statements line 1574 at r1 (raw file):

Previously, xinhaoz (Xin Hao Zhang) wrote…

Maybe we can add a logic test with the case you saw in the issue or similar

Tests added

@maryliag maryliag force-pushed the distinct-merge branch 3 times, most recently from 0d3dc2d to 989bbc7 Compare August 12, 2022 00:15
Previously, because we were using a join, we were double
counting statistics when we had the same fingerprint in
memory and persisted that had more than one index
recommendation.
This commit adds a `DISTINCT` so we only count them once.

Fixes cockroachdb#85958

Release note: None
Copy link
Member

@xinhaoz xinhaoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm_strong:

Reviewed 1 of 1 files at r2.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @xinhaoz)

@maryliag
Copy link
Contributor Author

TFTR!
bors r+

@craig
Copy link
Contributor

craig bot commented Aug 12, 2022

Build succeeded:

@craig craig bot merged commit ff3fc7e into cockroachdb:master Aug 12, 2022
@maryliag maryliag deleted the distinct-merge branch August 12, 2022 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

crdb_internal.statement_statistics returning wrong value
3 participants