mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-22 04:47:29 -06:00
[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()
This commit is contained in:
parent
faae2505c0
commit
a5852fd7e4
13 changed files with 151 additions and 29 deletions
|
|
@ -21,6 +21,7 @@ package bundb
|
|||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
|
|
@ -39,7 +40,8 @@ func (d *domainDB) IsDomainBlocked(ctx context.Context, domain string) (bool, db
|
|||
q := d.conn.
|
||||
NewSelect().
|
||||
Model(>smodel.DomainBlock{}).
|
||||
Where("LOWER(domain) = LOWER(?)", domain).
|
||||
ExcludeColumn("id", "created_at", "updated_at", "created_by_account_id", "private_comment", "public_comment", "obfuscate", "subscription_id").
|
||||
Where("domain = ?", domain).
|
||||
Limit(1)
|
||||
|
||||
return d.conn.Exists(ctx, q)
|
||||
|
|
@ -50,7 +52,7 @@ func (d *domainDB) AreDomainsBlocked(ctx context.Context, domains []string) (boo
|
|||
uniqueDomains := util.UniqueStrings(domains)
|
||||
|
||||
for _, domain := range uniqueDomains {
|
||||
if blocked, err := d.IsDomainBlocked(ctx, domain); err != nil {
|
||||
if blocked, err := d.IsDomainBlocked(ctx, strings.ToLower(domain)); err != nil {
|
||||
return false, err
|
||||
} else if blocked {
|
||||
return blocked, nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue