Skip to content

Commit

Permalink
Reduce CTE strategy usage when not needed (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgdigital authored Jul 4, 2024
1 parent abdb714 commit 6cf825b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
5 changes: 1 addition & 4 deletions internal/database/query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,13 +717,10 @@ func (b optionBuilder) shouldTryCteStrategy() bool {
if !b.limit.Valid || len(b.orderBy) == 0 {
return false
}
if b.tsquery != "" {
return true
}
for _, f := range b.facets {
if f.TriggersCte() && len(f.Filter()) > 0 {
return true
}
}
return false
return b.tsquery != "" && (len(b.orderBy) != 1 || b.orderBy[0].Column.Name != QueryStringRankField || !b.orderBy[0].Desc)
}
1 change: 0 additions & 1 deletion internal/database/search/facet_torrent_content_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ func TorrentContentTypeFacet(options ...query.FacetOption) query.Facet {
query.FacetHasKey(TorrentContentTypeFacetKey),
query.FacetHasLabel("Content Type"),
query.FacetUsesOrLogic(),
query.FacetTriggersCte(),
}, options...)...,
),
field: func(q *dao.Query) field.Field {
Expand Down

0 comments on commit 6cf825b

Please sign in to comment.