From a5852fd7e43bf97ea7def9de20cd6d02d954094d Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Mon, 2 May 2022 12:53:46 +0200 Subject: [performance] Speed up some of the slower db queries (#523) * remove unnecessary LOWER() db calls * warn during slow db queries * use bundb built-in exists function * add db block test * update account block query * add domain block db test * optimize domain block query * fix implementing wrong test * exclude most columns when checking block * go fmt * remote more unnecessary use of LOWER() --- internal/db/bundb/conn.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'internal/db/bundb/conn.go') diff --git a/internal/db/bundb/conn.go b/internal/db/bundb/conn.go index 3b5a3ac92..baa0baeae 100644 --- a/internal/db/bundb/conn.go +++ b/internal/db/bundb/conn.go @@ -68,13 +68,12 @@ func (conn *DBConn) ProcessError(err error) db.Error { // Exists checks the results of a SelectQuery for the existence of the data in question, masking ErrNoEntries errors func (conn *DBConn) Exists(ctx context.Context, query *bun.SelectQuery) (bool, db.Error) { - // Get the select query result - count, err := query.Count(ctx) + exists, err := query.Exists(ctx) // Process error as our own and check if it exists switch err := conn.ProcessError(err); err { case nil: - return (count != 0), nil + return exists, nil case db.ErrNoEntries: return false, nil default: -- cgit v1.2.3