-
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 1 commit
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
19 changes: 19 additions & 0 deletions
19
bootstrap/sql/migrations/native/2.0.2/mysql/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,19 @@ | ||
| -- Restore a composite index on profiler_data_time_series(entityFQNHash, extension, timestamp). | ||
| -- | ||
| -- Root cause: the 1.9.9 postDataMigrationSQLScript.sql created several temporary indexes for | ||
| -- the data migration and then dropped ALL of them at the end, including the only index that | ||
| -- covered entityFQNHash. After that migration the table retains only the unique constraint | ||
| -- (entityFQNHash, extension, operation, timestamp) where `operation` sits between `extension` | ||
| -- and `timestamp`. Queries of the form | ||
| -- | ||
| -- SELECT entityFQNHash, MAX(timestamp) FROM profiler_data_time_series | ||
| -- WHERE entityFQNHash IN (...) AND extension = 'table.columnProfile' | ||
| -- GROUP BY entityFQNHash | ||
| -- | ||
| -- cannot use that index efficiently for MAX(timestamp) because `operation` (nullable) breaks | ||
| -- the prefix. On a large table (millions of profile rows) this causes a full table scan and | ||
| -- 100+ second response times on the columns API when `fields=profile` is requested. | ||
| -- | ||
| -- The new index covers the exact predicate pattern used by getLatestExtensionsBatch(). | ||
| CREATE INDEX IF NOT EXISTS idx_pdts_fqnhash_ext_ts | ||
| ON profiler_data_time_series (entityFQNHash, extension, timestamp); | ||
|
sonika-shah marked this conversation as resolved.
Outdated
|
||
23 changes: 23 additions & 0 deletions
23
bootstrap/sql/migrations/native/2.0.2/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,23 @@ | ||
| -- Restore a composite index on profiler_data_time_series(entityFQNHash, extension, timestamp). | ||
| -- | ||
| -- Root cause: the 1.9.9 schemaChanges.sql explicitly dropped the unique constraint | ||
| -- profiler_data_time_series_unique_hash_extension_ts (entityFQNHash, extension, operation, timestamp) | ||
| -- to allow changing the `operation` generated-column expression, but never recreated it. | ||
| -- After the 1.9.9 migration the table retains only | ||
| -- profiler_data_time_series_combined_id_ts (extension, timestamp) | ||
| -- which is useless for queries that filter by entityFQNHash. | ||
| -- | ||
| -- The 1.9.9 postDataMigrationSQLScript.sql also created temporary indexes | ||
| -- (idx_pdts_entityFQNHash, idx_pdts_composite, etc.) during its bulk UPDATE pass and then | ||
| -- dropped them all, leaving no index on entityFQNHash. | ||
| -- | ||
| -- Queries of the form | ||
| -- | ||
| -- SELECT entityFQNHash, MAX(timestamp) FROM profiler_data_time_series | ||
| -- WHERE entityFQNHash IN (...) AND extension = 'table.columnProfile' | ||
| -- GROUP BY entityFQNHash | ||
| -- | ||
| -- issued by getLatestExtensionsBatch() perform a full table scan without this index, | ||
| -- causing 100+ second response times on the columns API when `fields=profile` is requested. | ||
| CREATE INDEX IF NOT EXISTS idx_pdts_fqnhash_ext_ts | ||
| ON profiler_data_time_series (entityFQNHash, extension, timestamp); |
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
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.