summaryrefslogtreecommitdiff
path: root/internal/db/bundb/trace.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-05-02 12:53:46 +0200
committerLibravatar GitHub <noreply@github.com>2022-05-02 11:53:46 +0100
commita5852fd7e43bf97ea7def9de20cd6d02d954094d (patch)
treed72b7fe9bf603786a5533e6b566a8412b2b8f634 /internal/db/bundb/trace.go
parentAdd logging to the new generic worker package (#516) (diff)
downloadgotosocial-a5852fd7e43bf97ea7def9de20cd6d02d954094d.tar.xz
[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()
Diffstat (limited to 'internal/db/bundb/trace.go')
-rw-r--r--internal/db/bundb/trace.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/internal/db/bundb/trace.go b/internal/db/bundb/trace.go
index 93c231785..27b5e22ac 100644
--- a/internal/db/bundb/trace.go
+++ b/internal/db/bundb/trace.go
@@ -47,6 +47,11 @@ func (q *debugQueryHook) AfterQuery(_ context.Context, event *bun.QueryEvent) {
"operation": event.Operation(),
})
+ if dur > 1*time.Second {
+ l.Warnf("SLOW DATABASE QUERY [%s] %s", dur, event.Query)
+ return
+ }
+
if logrus.GetLevel() == logrus.TraceLevel {
l.Tracef("[%s] %s", dur, event.Query)
} else {