Perf/Postgres Index Optimization and Benchmarking#984
Merged
tolgaozen merged 5 commits intoPermify:masterfrom Jan 2, 2024
Merged
Perf/Postgres Index Optimization and Benchmarking#984tolgaozen merged 5 commits intoPermify:masterfrom
tolgaozen merged 5 commits intoPermify:masterfrom
Conversation
tolgaozen
reviewed
Jan 2, 2024
Member
tolgaozen
left a comment
There was a problem hiding this comment.
Can you create and drop indexes using 'CONCURRENTLY'?
Contributor
Author
|
@tolgaozen yes for sure |
Contributor
Author
|
@tolgaozen done Test: |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes: #863
/claim #863
Optimization Process
Initial Analysis
EXPLAIN ANALYZE,generate_series(for test data generation) both directly inPGAdmin1. retreival from
schema_definitionsusesversionandtenant_idas filter. For this query by default postgres use sequential scan.Index Optimization
Optimization Strategies: Detail the specific index optimizations implemented.
versionofschema_definitionsImplementation Details:
1=> 24c1413Benchmarking Setup
Environment Details
Benchmarking Methodology
Queries Tested: All the queries from
internal/enginesfolder.Query 1:
SELECT name, serialized_definition, version FROM public.schema_definitions WHERE name= :name AND version= :version AND tenant_id= :tenant_id' LIMIT 1;Benchmark Results
Before Optimization
*
1k: 0.230 ms*
10k: 2.9 msAfter Optimization
*
1k: 0.040 ms*
10k: 0.060 msAnalysis and Conclusions
Performance Improvements: Query speed improved by huge margin.
Recommendations&Conclusions:
relation_tuples&attributes.schemaI have added new index which coversversionfor one of the query wherenameis not used. i.eReadSchema.created_tx_id,'expired_tx_id' in index since both are covered inUnique Constraint.Adttional notes:
EntityFilterandSubjectFilterinternal/storagecan use index optimization since this was out of scope didn't add as commit.brinindex ontimestampoftransaction. But since query time is every200hours and also previous transactions gets deleted, this can be ignored.Happy New Year!!!!