-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jdbc): improve JDBC PostgreSQL queues queries performance (#1883)
close #1121
- Loading branch information
1 parent
23faaa8
commit a6b28d6
Showing
6 changed files
with
27 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
DROP INDEX logs_namespace; | ||
DROP INDEX logs_timestamp; | ||
CREATE INDEX logs_namespace_flow ON logs ("deleted", "timestamp", "level", "namespace", "flow_id"); |
File renamed without changes.
8 changes: 0 additions & 8 deletions
8
jdbc-postgres/src/main/resources/migrations/postgres/V13__queue_index_optim.sql
This file was deleted.
Oops, something went wrong.
File renamed without changes.
3 changes: 0 additions & 3 deletions
3
jdbc-postgres/src/main/resources/migrations/postgres/V21_index_logs.sql
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
jdbc-postgres/src/main/resources/migrations/postgres/V22__index_queues.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,24 @@ | ||
-- Recreate the queues_type__* indexes by adding the offset column otherwise the index is not used as we order on offset. | ||
-- Also make them partial to lower the index size. | ||
DROP INDEX queues_type__consumer_flow_topology; | ||
DROP INDEX queues_type__consumer_indexer; | ||
DROP INDEX queues_type__consumer_executor; | ||
DROP INDEX queues_type__consumer_worker; | ||
DROP INDEX queues_type__consumer_scheduler; | ||
|
||
CREATE INDEX queues_type__consumer_flow_topology ON queues (type, consumer_flow_topology, "offset") WHERE consumer_flow_topology = false; | ||
CREATE INDEX queues_type__consumer_indexer ON queues (type, consumer_indexer, "offset") WHERE consumer_indexer = false; | ||
CREATE INDEX queues_type__consumer_executor ON queues (type, consumer_executor, "offset") WHERE consumer_executor = false; | ||
CREATE INDEX queues_type__consumer_worker ON queues (type, consumer_worker, "offset") WHERE consumer_worker = false; | ||
CREATE INDEX queues_type__consumer_scheduler ON queues (type, consumer_scheduler, "offset") WHERE consumer_scheduler = false; | ||
|
||
-- Go back to the original PK and queues_offset__type as they are useful for offset based poll and updates | ||
DO $$ | ||
BEGIN | ||
IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'queues' and constraint_type = 'PRIMARY KEY') then | ||
ALTER TABLE queues ADD PRIMARY KEY("offset"); | ||
END IF; | ||
END; | ||
$$; | ||
DROP INDEX IF EXISTS queues_offset; | ||
CREATE INDEX IF NOT EXISTS queues_type__offset ON queues (type, "offset"); |