Fix exclude filter query performance (#1815)

* Fix query performance
* Reorder changelog changes by size to prepare for release
This commit is contained in:
kermieisinthehouse
2021-10-10 08:02:26 +00:00
committed by GitHub
parent 04ca11e62e
commit c31c7c3c99
3 changed files with 15 additions and 14 deletions

View File

@@ -448,8 +448,8 @@ func (m *joinedMultiCriterionHandlerBuilder) handler(criterion *models.MultiCrit
} else if criterion.Modifier == models.CriterionModifierExcludes {
// excludes all of the provided ids
// need to use actual join table name for this
// not exists (select <joinTable>.<primaryFK> from <joinTable> where <joinTable>.<primaryFK> = <primaryTable>.id and <joinTable>.<foreignFK> in <values>)
whereClause = fmt.Sprintf("not exists (select %[1]s.%[2]s from %[1]s where %[1]s.%[2]s = %[3]s.id and %[1]s.%[4]s in %[5]s)", m.joinTable, m.primaryFK, m.primaryTable, m.foreignFK, getInBinding(len(criterion.Value)))
// <primaryTable>.id NOT IN (select <joinTable>.<primaryFK> from <joinTable> where <joinTable>.<foreignFK> in <values>)
whereClause = fmt.Sprintf("%[1]s.id NOT IN (SELECT %[3]s.%[2]s from %[3]s where %[3]s.%[4]s in %[5]s)", m.primaryTable, m.primaryFK, m.joinTable, m.foreignFK, getInBinding(len(criterion.Value)))
}
f.addWhere(whereClause, args...)

View File

@@ -211,7 +211,7 @@ func getMultiCriterionClause(primaryTable, foreignTable, joinTable, primaryFK, f
} else if criterion.Modifier == models.CriterionModifierExcludes {
// excludes all of the provided ids
if joinTable != "" {
whereClause = "not exists (select " + joinTable + "." + primaryFK + " from " + joinTable + " where " + joinTable + "." + primaryFK + " = " + primaryTable + ".id and " + joinTable + "." + foreignFK + " in " + getInBinding(len(criterion.Value)) + ")"
whereClause = primaryTable + ".id not in (select " + joinTable + "." + primaryFK + " from " + joinTable + " where " + joinTable + "." + foreignFK + " in " + getInBinding(len(criterion.Value)) + ")"
} else {
whereClause = "not exists (select s.id from " + primaryTable + " as s where s.id = " + primaryTable + ".id and s." + foreignFK + " in " + getInBinding(len(criterion.Value)) + ")"
}

View File

@@ -3,41 +3,42 @@
#### 💥 Note: The system will now stop serving requests if authentication is not configured and it detects a connection from public internet. See [this link](https://github.com/stashapp/stash/wiki/Authentication-Required-When-Accessing-Stash-From-the-Internet) for details.
### ✨ New Features
* Disallow access from public internet addresses when authentication is not configured. ([#1761](https://github.com/stashapp/stash/pull/1761))
* Added support for Tag hierarchies. ([#1519](https://github.com/stashapp/stash/pull/1519))
* Revamped image lightbox to support zoom, pan and various display modes. ([#1708](https://github.com/stashapp/stash/pull/1708))
* Added support for Studio aliases. ([#1660](https://github.com/stashapp/stash/pull/1660))
* Added native support for Apple Silicon / M1 Macs. ([#1646](https://github.com/stashapp/stash/pull/1646))
* Support subpaths when serving stash via reverse proxy. ([#1719](https://github.com/stashapp/stash/pull/1719))
* Disallow access from public internet addresses when authentication is not configured. ([#1761](https://github.com/stashapp/stash/pull/1761))
* Added options to generate webp and static preview files for markers. ([#1604](https://github.com/stashapp/stash/pull/1604))
* Added sort by option for gallery rating. ([#1720](https://github.com/stashapp/stash/pull/1720))
* Added support for querying scene scrapers using keywords. ([#1712](https://github.com/stashapp/stash/pull/1712))
* Added support for Studio aliases. ([#1660](https://github.com/stashapp/stash/pull/1660))
* Added support for Tag hierarchies. ([#1519](https://github.com/stashapp/stash/pull/1519))
* Added native support for Apple Silicon / M1 Macs. ([#1646](https://github.com/stashapp/stash/pull/1646))
* Added Movies to Scene bulk edit dialog. ([#1676](https://github.com/stashapp/stash/pull/1676))
* Added Movies tab to Studio and Performer pages. ([#1675](https://github.com/stashapp/stash/pull/1675))
* Support filtering Movies by Performers. ([#1675](https://github.com/stashapp/stash/pull/1675))
### 🎨 Improvements
* Support setting metadata import/export directory from UI. ([#1782](https://github.com/stashapp/stash/pull/1782))
* Optimised image thumbnail generation (optionally using `libvips`) and made optional. ([#1655](https://github.com/stashapp/stash/pull/1655))
* Added missing image table indexes, resulting in a significant performance improvement. ([#1740](https://github.com/stashapp/stash/pull/1740))
* Improved image query performance. ([#1750](https://github.com/stashapp/stash/pull/1750))
* Added sv-SE language option. ([#1691](https://github.com/stashapp/stash/pull/1691))
* Support setting metadata import/export directory from UI. ([#1782](https://github.com/stashapp/stash/pull/1782))
* Added movie count to performer and studio cards. ([#1760](https://github.com/stashapp/stash/pull/1760))
* Added date and details to Movie card, and move scene count to icon. ([#1758](https://github.com/stashapp/stash/pull/1758))
* Added date and details to Gallery card, and move image count to icon. ([#1763](https://github.com/stashapp/stash/pull/1763))
* Optimised image thumbnail generation (optionally using `libvips`) and made optional. ([#1655](https://github.com/stashapp/stash/pull/1655))
* Added missing image table indexes, resulting in a significant performance improvement. ([#1740](https://github.com/stashapp/stash/pull/1740))
* Support scraper script logging to specific log levels. ([#1648](https://github.com/stashapp/stash/pull/1648))
* Added sv-SE language option. ([#1691](https://github.com/stashapp/stash/pull/1691))
### 🐛 Bug fixes
* Fix video player aspect ratio shifting sometimes when clicking scene tabs. ([#1764](https://github.com/stashapp/stash/pull/1764))
* Disabled float-on-scroll player on mobile devices. ([#1721](https://github.com/stashapp/stash/pull/1721))
* Fix video transcoding process starting before video is played. ([#1780](https://github.com/stashapp/stash/pull/1780))
* Fix Scene Edit Panel form layout for mobile and desktop. ([#1737](https://github.com/stashapp/stash/pull/1737))
* Don't scan zero-length files. ([#1779](https://github.com/stashapp/stash/pull/1779))
* Accept svg files in file selector for tag images. ([#1778](https://github.com/stashapp/stash/pull/1778))
* Optimised exclude filter queries. ([#1815](https://github.com/stashapp/stash/pull/1815))
* Fix video player aspect ratio shifting sometimes when clicking scene tabs. ([#1764](https://github.com/stashapp/stash/pull/1764))
* Fix criteria being incorrectly applied when clicking back button. ([#1765](https://github.com/stashapp/stash/pull/1765))
* Show first page and fix order direction not being maintained when clicking on card popover button. ([#1765](https://github.com/stashapp/stash/pull/1765))
* Fix panic in autotagger when backslash character present in tag/performer/studio name. ([#1753](https://github.com/stashapp/stash/pull/1753))
* Fix Scene Player CLS issue ([#1739](https://github.com/stashapp/stash/pull/1739))
* Fix Scene Edit Panel form layout for mobile and desktop. ([#1737](https://github.com/stashapp/stash/pull/1737))
* Fix Gallery create plugin hook not being invoked when creating Gallery from folder. ([#1731](https://github.com/stashapp/stash/pull/1731))
* Fix tag aliases not being matched when autotagging from the tasks page. ([#1713](https://github.com/stashapp/stash/pull/1713))
* Disabled float-on-scroll player on mobile devices. ([#1721](https://github.com/stashapp/stash/pull/1721))
* Fix Create Marker form on small devices. ([#1718](https://github.com/stashapp/stash/pull/1718))