mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Speed up tag count queries (#570)
* Speed up tag count queries * Add test for marker CountByTagID Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
@@ -35,10 +35,10 @@ WHERE movies_join.movie_id = ?
|
||||
GROUP BY scenes.id
|
||||
`
|
||||
|
||||
var scenesForTagQuery = selectAll(sceneTable) + `
|
||||
LEFT JOIN scenes_tags as tags_join on tags_join.scene_id = scenes.id
|
||||
WHERE tags_join.tag_id = ?
|
||||
GROUP BY scenes.id
|
||||
var countScenesForTagQuery = `
|
||||
SELECT tag_id AS id FROM scenes_tags
|
||||
WHERE scenes_tags.tag_id = ?
|
||||
GROUP BY scenes_tags.scene_id
|
||||
`
|
||||
|
||||
type SceneQueryBuilder struct{}
|
||||
@@ -212,7 +212,7 @@ func (qb *SceneQueryBuilder) CountByStudioID(studioID int) (int, error) {
|
||||
|
||||
func (qb *SceneQueryBuilder) CountByTagID(tagID int) (int, error) {
|
||||
args := []interface{}{tagID}
|
||||
return runCountQuery(buildCountQuery(scenesForTagQuery), args)
|
||||
return runCountQuery(buildCountQuery(countScenesForTagQuery), args)
|
||||
}
|
||||
|
||||
func (qb *SceneQueryBuilder) Wall(q *string) ([]*Scene, error) {
|
||||
|
||||
Reference in New Issue
Block a user