Skip to content

Commit

Permalink
[MM-53408] server/user_store: avoid antijoin for IsEmpty query (matte…
Browse files Browse the repository at this point in the history
  • Loading branch information
isacikgoz committed Jul 20, 2023
1 parent 6c821c8 commit a307fd9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/channels/store/sqlstore/user_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -2140,7 +2140,11 @@ func (us SqlUserStore) IsEmpty(excludeBots bool) (bool, error) {
From("Users")

if excludeBots {
builder = builder.LeftJoin("Bots ON Users.Id = Bots.UserId").Where("Bots.UserId IS NULL")
if us.DriverName() == model.DatabaseDriverPostgres {
builder = builder.LeftJoin("Bots ON Users.Id = Bots.UserId").Where("Bots.UserId IS NULL")
} else {
builder = builder.Where(sq.Expr("Users.Id NOT IN (SELECT UserId FROM Bots)"))
}
}

builder = builder.Suffix(")")
Expand Down

0 comments on commit a307fd9

Please sign in to comment.