Skip to content
This repository was archived by the owner on Nov 9, 2022. It is now read-only.

Commit 5408ff5

Browse files
committed
Improve indices
1 parent 5b0369a commit 5408ff5

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

bin/index.create.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ CREATE INDEX "index_domain_transactions" ON transactions USING BTREE ("domain");
2424
CREATE INDEX "index_app_transactions" ON transactions USING BTREE ("app");
2525
CREATE INDEX "index_App-Name_transactions" ON transactions USING BTREE ("App-Name");
2626
27-
CREATE INDEX "tags_name" ON tags USING BTREE ("name");
28-
CREATE INDEX "tags_value" ON tags USING BTREE ("value");
29-
CREATE INDEX "tags_name_value" ON tags USING BTREE ("name", "value");
30-
CREATE INDEX "tags_tx_id_name" ON tags USING BTREE ("tx_id", "name");
27+
CREATE INDEX "tags_name" ON tags USING BTREE ("name") WHERE LENGTH("name") < 64;
28+
CREATE INDEX "tags_value" ON tags USING BTREE ("value") WHERE LENGTH("value") < 64;
29+
CREATE INDEX "tags_name_value" ON tags USING BTREE ("name", "value") WHERE LENGTH("name") < 64 AND LENGTH("value") < 64;
30+
CREATE INDEX "tags_tx_id_name" ON tags USING BTREE ("tx_id", "name") WHERE LENGTH("name") < 64;
31+
CREATE INDEX "tags_tx_id" ON tags USING BTREE ("tx_id");
3132
3233
EOF
3334

bin/index.drop.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ DROP INDEX "tags_name";
1010
DROP INDEX "tags_value";
1111
DROP INDEX "tags_name_value";
1212
DROP INDEX "tags_tx_id_name";
13+
DROP INDEX "tags_tx_id";
1314
1415
DROP INDEX "index_App-Name_transactions";
1516
DROP INDEX "index_app_transactions";

migrations/20200404025828_initialize.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export async function up(knex: Knex) {
6262
table.index(['name'], 'tags_name', 'BTREE');
6363
table.index(['value'], 'tags_value', 'BTREE');
6464
table.index(['name', 'value'], 'tags_name_value', 'BTREE');
65+
table.index(['tx_id'], 'tags_tx_id', 'BTREE');
6566
});
6667
}
6768

0 commit comments

Comments
 (0)