Skip to content

Commit

Permalink
Optimization: get address query (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Jun 17, 2024
1 parent bff4039 commit bd6504c
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions internal/storage/postgres/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ func NewAddress(db *database.Bun) *Address {
func (a *Address) ByHash(ctx context.Context, hash []byte) (address storage.Address, err error) {
addressQuery := a.DB().NewSelect().
Model((*storage.Address)(nil)).
Where("hash = ?", hash).
Order("id asc").
Limit(1)
Where("hash = ?", hash)

err = a.DB().NewSelect().TableExpr("(?) as address", addressQuery).
ColumnExpr("address.*").
Expand Down Expand Up @@ -103,7 +101,6 @@ func (a *Address) IdByHash(ctx context.Context, hash []byte) (id uint64, err err
Model((*storage.Address)(nil)).
Column("id").
Where("hash = ?", hash).
Limit(1).
Scan(ctx, &id)
return
}

0 comments on commit bd6504c

Please sign in to comment.