Skip to content

Commit

Permalink
Add Indexes to candles and orders to optimize queries (#1060)
Browse files Browse the repository at this point in the history
* Add Indexes to candles and orders to optimize queries

* update naming
  • Loading branch information
Christopher-Li authored Feb 9, 2024
1 parent 72cc5d6 commit 450ce8b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as Knex from 'knex';

export async function up(knex: Knex): Promise<void> {
// eslint-disable-next-line @typescript-eslint/quotes
await knex.raw(`
CREATE INDEX CONCURRENTLY IF NOT EXISTS candles_ticker_resolution_index ON candles("ticker", "resolution");
`);
}

export async function down(knex: Knex): Promise<void> {
await knex.raw(`
DROP INDEX CONCURRENTLY IF EXISTS "candles_ticker_resolution_index";
`);
}

export const config = {
transaction: false,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as Knex from 'knex';

export async function up(knex: Knex): Promise<void> {
// eslint-disable-next-line @typescript-eslint/quotes
await knex.raw(`
CREATE INDEX CONCURRENTLY IF NOT EXISTS orders_clobPairId_subaccountId_index ON orders("clobPairId", "subaccountId");
`);
}

export async function down(knex: Knex): Promise<void> {
await knex.raw(`
DROP INDEX CONCURRENTLY IF EXISTS "orders_clobPairId_subaccountId_index";
`);
}

export const config = {
transaction: false,
};

0 comments on commit 450ce8b

Please sign in to comment.