-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: optimize pipelinereports table to improve performances (#127)
* feat: rework sql queries * convert query into subqueries Signed-off-by: Olivier Vernin <[email protected]> * Convert json table to jsonb and add variouse indexes * fix: add missing ; to sql migration Signed-off-by: Olivier Vernin <[email protected]> --------- Signed-off-by: Olivier Vernin <[email protected]>
- Loading branch information
Showing
4 changed files
with
77 additions
and
31 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
pkg/database/migrations/000003_alter_pipelineReports_jsonb.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,10 @@ | ||
ALTER TABLE pipelineReports | ||
ALTER COLUMN data | ||
SET DATA TYPE JSON | ||
USING data::JSON; | ||
|
||
DROP INDEX idx_pipelinereports_data_jsonb; | ||
DROP INDEX idx_pipelinereports_updated_at; | ||
DROP INDEX idx_pipelinereports_data_name; | ||
DROP INDEX idx_pipelinereports_data_result; | ||
DROP INDEX idx_pipelinereports_distinct; |
22 changes: 22 additions & 0 deletions
22
pkg/database/migrations/000003_alter_pipelineReports_jsonb.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,22 @@ | ||
ALTER TABLE pipelineReports | ||
ALTER COLUMN data | ||
SET DATA TYPE JSONB | ||
USING data::JSONB; | ||
|
||
CREATE INDEX idx_pipelinereports_data_jsonb | ||
ON pipelinereports | ||
USING gin (data jsonb_path_ops); | ||
|
||
CREATE INDEX idx_pipelinereports_updated_at | ||
ON pipelinereports (updated_at); | ||
|
||
CREATE INDEX idx_pipelinereports_data_name | ||
ON pipelinereports ((data ->> 'Name')); | ||
|
||
CREATE INDEX idx_pipelinereports_data_result | ||
ON pipelinereports ((data ->> 'Result')); | ||
|
||
CREATE INDEX idx_pipelinereports_distinct | ||
ON pipelinereports ( | ||
(data ->> 'Name'), updated_at DESC | ||
); |
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