mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Improve performance of gallery and image queries (#2422)
* Revert to use FindByGalleryID in gallery resolver * Sort by path in FindByGalleryID * Optimise queries
This commit is contained in:
@@ -194,11 +194,20 @@ func getMultiCriterionClause(primaryTable, foreignTable, joinTable, primaryFK, f
|
||||
switch criterion.Modifier {
|
||||
case models.CriterionModifierIncludes:
|
||||
// includes any of the provided ids
|
||||
whereClause = foreignTable + ".id IN " + getInBinding(len(criterion.Value))
|
||||
if joinTable != "" {
|
||||
whereClause = joinTable + "." + foreignFK + " IN " + getInBinding(len(criterion.Value))
|
||||
} else {
|
||||
whereClause = foreignTable + ".id IN " + getInBinding(len(criterion.Value))
|
||||
}
|
||||
case models.CriterionModifierIncludesAll:
|
||||
// includes all of the provided ids
|
||||
whereClause = foreignTable + ".id IN " + getInBinding(len(criterion.Value))
|
||||
havingClause = "count(distinct " + foreignTable + ".id) IS " + strconv.Itoa(len(criterion.Value))
|
||||
if joinTable != "" {
|
||||
whereClause = joinTable + "." + foreignFK + " IN " + getInBinding(len(criterion.Value))
|
||||
havingClause = "count(distinct " + joinTable + "." + foreignFK + ") IS " + strconv.Itoa(len(criterion.Value))
|
||||
} else {
|
||||
whereClause = foreignTable + ".id IN " + getInBinding(len(criterion.Value))
|
||||
havingClause = "count(distinct " + foreignTable + ".id) IS " + strconv.Itoa(len(criterion.Value))
|
||||
}
|
||||
case models.CriterionModifierExcludes:
|
||||
// excludes all of the provided ids
|
||||
if joinTable != "" {
|
||||
|
||||
Reference in New Issue
Block a user