Skip to content

Commit

Permalink
Add index on locked_by field
Browse files Browse the repository at this point in the history
  • Loading branch information
boecklim committed Dec 11, 2023
1 parent 851bbf7 commit 50a8245
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ CREATE TABLE metamorph.transactions (
inserted_at_num INTEGER DEFAULT TO_NUMBER(TO_CHAR((NOW()) AT TIME ZONE 'UTC', 'yyyymmddhh24'), '9999999999') NOT NULL
);

CREATE INDEX ix_metamorph_transactions_locked_by ON metamorph.transactions (locked_by);
CREATE INDEX ix_metamorph_transactions_inserted_at_num ON metamorph.transactions (inserted_at_num);
2 changes: 1 addition & 1 deletion metamorph/store/postgresql/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ func (p *PostgreSQL) GetUnmined(ctx context.Context, callback func(s *store.Stor
,merkle_proof
,raw_tx
,locked_by
FROM metamorph.transactions WHERE (status < $1 OR status = $2 ) AND locked_by = 'NONE';`
FROM metamorph.transactions WHERE locked_by = 'NONE' AND (status < $1 OR status = $2 );`

rows, err := p.db.QueryContext(ctx, q, metamorph_api.Status_MINED, metamorph_api.Status_SEEN_IN_ORPHAN_MEMPOOL)
if err != nil {
Expand Down

0 comments on commit 50a8245

Please sign in to comment.