Skip to content

Commit

Permalink
perf(db): add rollup indexes (#558)
Browse files Browse the repository at this point in the history
* perf(db): remove rendundant block number index

* perf(db): add rollup index keys

* perf(db): add transaction sender/receiver indexes
  • Loading branch information
PJColombo authored Sep 10, 2024
1 parent 253f293 commit 359df4e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- DropIndex
DROP INDEX "transaction_block_number_idx";
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- DropIndex
DROP INDEX "transaction_category_idx";

-- CreateIndex
CREATE INDEX "transaction_category_rollup_block_number_index_idx" ON "transaction"("category", "rollup", "block_number", "index");
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- DropIndex
DROP INDEX "transaction_block_timestamp_idx";

-- CreateIndex
CREATE INDEX "transaction_block_timestamp_category_rollup_block_number_in_idx" ON "transaction"("block_timestamp", "category", "rollup", "block_number", "index");

-- CreateIndex
CREATE INDEX "transaction_from_id_block_number_index_idx" ON "transaction"("from_id", "block_number", "index");

-- CreateIndex
CREATE INDEX "transaction_to_id_block_number_index_idx" ON "transaction"("to_id", "block_number", "index");
7 changes: 4 additions & 3 deletions packages/db/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,11 @@ model Transaction {
@@index([insertedAt])
@@index([blockHash])
@@index([blockNumber])
@@index([blockNumber, index])
@@index([blockTimestamp])
@@index([category])
@@index([blockTimestamp, category, rollup, blockNumber, index])
@@index([category, rollup, blockNumber, index])
@@index([fromId, blockNumber, index])
@@index([toId, blockNumber, index])
@@map("transaction")
}

Expand Down

0 comments on commit 359df4e

Please sign in to comment.