-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix(profiler): N+1 / missing-index regression on /tables/.../columns?fields=profile (#3488) #27746
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
Open
sonika-shah
wants to merge
6
commits into
main
Choose a base branch
from
fix/profiler-n1-missing-index-3488
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
72f6df3
fix(profiler): N+1 / missing-index regression on /tables/.../columns?…
claude b7ead17
Merge branch 'main' into fix/profiler-n1-missing-index-3488
sonika-shah eddb32c
fix(profiler): restore unique constraint on profiler_data_time_series…
sonika-shah 38bf22e
chore(profiler): address review feedback — empty-list literal + accur…
sonika-shah ec22ab6
fix(profiler): force outer index scan in getLatestExtensionsBatch by …
sonika-shah 458bc91
test(profiler): shorten classification/tag fixture names in IT to fit…
sonika-shah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
bootstrap/sql/migrations/native/1.12.8/postgres/schemaChanges.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| -- Restore the unique constraint dropped in 1.9.9. Closes the 1.9.9 regression that caused | ||
| -- /columns?fields=profile 504s, and brings Postgres back in line with MySQL (which never | ||
| -- lost it). The leading (entityFQNHash, extension) prefix serves the column-profile batch query. | ||
| -- Two-phase: CONCURRENTLY build avoids ACCESS EXCLUSIVE lock; ADD CONSTRAINT USING INDEX | ||
| -- promotes the built index without re-scanning. | ||
| CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS | ||
| profiler_data_time_series_unique_hash_extension_ts | ||
| ON profiler_data_time_series (entityFQNHash, extension, operation, timestamp); | ||
|
|
||
| ALTER TABLE profiler_data_time_series | ||
| ADD CONSTRAINT profiler_data_time_series_unique_hash_extension_ts | ||
| UNIQUE USING INDEX profiler_data_time_series_unique_hash_extension_ts; | ||
|
sonika-shah marked this conversation as resolved.
sonika-shah marked this conversation as resolved.
|
||
|
|
||
| ANALYZE profiler_data_time_series; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1526,6 +1526,13 @@ void bulkUpsertExtensions( | |
| List<ExtensionRecord> getExtensions( | ||
| @BindUUID("id") UUID id, @Bind("extensionPrefix") String extensionPrefix); | ||
|
|
||
| @RegisterRowMapper(ExtensionMapper.class) | ||
| @SqlQuery( | ||
| "SELECT extension, json FROM entity_extension WHERE id = :id AND jsonschema = :jsonSchema " | ||
| + "ORDER BY extension") | ||
| List<ExtensionRecord> getExtensionsByJsonSchema( | ||
| @BindUUID("id") UUID id, @Bind("jsonSchema") String jsonSchema); | ||
|
|
||
| @ConnectionAwareSqlQuery( | ||
| value = | ||
| "SELECT json FROM (" | ||
|
|
@@ -9521,7 +9528,8 @@ default String getTimeSeriesTableName() { | |
| + " GROUP BY entityFQNHash" | ||
| + ") latest " | ||
| + "ON p.entityFQNHash = latest.entityFQNHash AND p.timestamp = latest.latestTs " | ||
| + "WHERE p.extension = :extension") | ||
| + "WHERE p.extension = :extension " | ||
| + "AND p.entityFQNHash IN (<entityFQNHashes>)") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you know what benefits we get in terms of performance by adding entityFqnHashes here since we already have this in the inner join table predicate. |
||
| @RegisterRowMapper(LatestExtensionRecordMapper.class) | ||
| List<LatestExtensionRecord> getLatestExtensionsBatch( | ||
| @Define("table") String table, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.