-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Indexes to candles and orders to optimize queries (#1060)
* Add Indexes to candles and orders to optimize queries * update naming
- Loading branch information
1 parent
72cc5d6
commit 450ce8b
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
...s/src/db/migrations/migration_files/20240208153050_add_candles_ticket_resolution_index.ts
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,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, | ||
}; |
18 changes: 18 additions & 0 deletions
18
.../db/migrations/migration_files/20240208161948_add_orders_clobpairid_subaccountid_index.ts
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,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, | ||
}; |