Skip to content

Commit

Permalink
add condition to ON CONFLICT to avoid not-needed writes
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaytonNorthey92 committed Jan 8, 2025
1 parent b8fa2a6 commit a110579
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion database/bfgd/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,8 @@ func (p *pgdb) L2KeystoneLowestBtcBlockUpsert(ctx context.Context, l2KeystoneAbr
(SELECT hash FROM lowest_btc_block),
(SELECT height FROM lowest_btc_block)
)
ON CONFLICT (l2_keystone_abrev_hash) DO UPDATE SET btc_block_hash = EXCLUDED.btc_block_hash
ON CONFLICT (l2_keystone_abrev_hash) DO UPDATE SET btc_block_hash = EXCLUDED.btc_block_hash
WHERE l2_keystones_lowest_btc_block.btc_block_hash != EXCLUDED.btc_block_hash
`

_, err := p.db.ExecContext(ctx, sql, l2KeystoneAbrevHash)
Expand Down

0 comments on commit a110579

Please sign in to comment.