Commit e5732d97 authored by Conner Fromknecht's avatar Conner Fromknecht

feat: add btree index on teleportr deposit.txn_hash/address

This will ensure performance on queries for a specific deposit by
txn_hash/address does not degrade as the table grows.
parent a9f2f570
---
'@eth-optimism/teleportr': patch
---
Add btree index on deposit.txn_hash and deposit.address
...@@ -63,6 +63,14 @@ CREATE TABLE IF NOT EXISTS deposits ( ...@@ -63,6 +63,14 @@ CREATE TABLE IF NOT EXISTS deposits (
); );
` `
const createDepositTxnHashIndex = `
CREATE INDEX ON deposits (txn_hash)
`
const createDepositAddressIndex = `
CREATE INDEX ON deposits (address)
`
const createDisbursementsTable = ` const createDisbursementsTable = `
CREATE TABLE IF NOT EXISTS disbursements ( CREATE TABLE IF NOT EXISTS disbursements (
id INT8 NOT NULL PRIMARY KEY REFERENCES deposits(id), id INT8 NOT NULL PRIMARY KEY REFERENCES deposits(id),
...@@ -91,6 +99,8 @@ CREATE TABLE IF NOT EXISTS pending_txs ( ...@@ -91,6 +99,8 @@ CREATE TABLE IF NOT EXISTS pending_txs (
var migrations = []string{ var migrations = []string{
createDepositsTable, createDepositsTable,
createDepositTxnHashIndex,
createDepositAddressIndex,
createDisbursementsTable, createDisbursementsTable,
lastProcessedBlockTable, lastProcessedBlockTable,
pendingTxTable, pendingTxTable,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment