-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1174 from jbrill/universe-index-optimizations
tapdb: Add Universe indices, optimize SQL queries, `RWMutex` for cache
- Loading branch information
Showing
11 changed files
with
551 additions
and
138 deletions.
There are no files selected for viewing
This file contains 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 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
5 changes: 5 additions & 0 deletions
5
tapdb/sqlc/migrations/000024_universe_optimization_indexes_queries.down.sql
This file contains 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,5 @@ | ||
DROP INDEX IF EXISTS idx_mssmt_nodes_stats; | ||
|
||
DROP INDEX IF EXISTS idx_universe_leaves_composite; | ||
|
||
DROP INDEX IF EXISTS idx_universe_roots_composite; |
14 changes: 14 additions & 0 deletions
14
tapdb/sqlc/migrations/000024_universe_optimization_indexes_queries.up.sql
This file contains 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 @@ | ||
-- Most impactful for query_asset_stats which currently has highest latency | ||
-- Supports the common join pattern and filters on proof_type. | ||
CREATE INDEX IF NOT EXISTS idx_universe_leaves_asset | ||
ON universe_leaves(asset_genesis_id, universe_root_id); | ||
|
||
-- Helps with the join conditions we frequently see | ||
-- This is especially useful for query_universe_leaves and improves join efficiency. | ||
CREATE INDEX IF NOT EXISTS idx_mssmt_nodes_composite | ||
ON mssmt_nodes(namespace, key, hash_key, sum); | ||
|
||
-- Optimizes the common namespace_root lookups along with proof_type filtering | ||
-- This helps with fetch_universe_root and roots-related queries. | ||
CREATE INDEX IF NOT EXISTS idx_universe_roots_composite | ||
ON universe_roots(namespace_root, proof_type, asset_id); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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.