[Files Refactor] Performance tuning (#2813)

* Do database txn in same thread. Retry on locked db
* Remove captions from slimscenedata
* Fix tracing
* Use where in instead of individual selects
* Remove scenes_query view
* Remove image query view
* Remove gallery query view
* Use where in for FindMany
* Don't interrupt scanning zip files
* Fix image filesize sort
This commit is contained in:
WithoutPants
2022-08-11 16:14:57 +10:00
parent 87167736f6
commit 9b31b20fed
19 changed files with 715 additions and 680 deletions

View File

@@ -44,6 +44,7 @@ func Test_imageQueryBuilder_Create(t *testing.T) {
GalleryIDs: []int{galleryIDs[galleryIdxWithImage]},
TagIDs: []int{tagIDs[tagIdx1WithImage], tagIDs[tagIdx1WithDupName]},
PerformerIDs: []int{performerIDs[performerIdx1WithImage], performerIDs[performerIdx1WithDupName]},
Files: []*file.ImageFile{},
},
false,
},
@@ -193,9 +194,12 @@ func Test_imageQueryBuilder_Update(t *testing.T) {
Files: []*file.ImageFile{
makeImageFileWithID(imageIdxWithGallery),
},
Organized: true,
CreatedAt: createdAt,
UpdatedAt: updatedAt,
GalleryIDs: []int{},
TagIDs: []int{},
PerformerIDs: []int{},
Organized: true,
CreatedAt: createdAt,
UpdatedAt: updatedAt,
},
false,
},
@@ -206,9 +210,12 @@ func Test_imageQueryBuilder_Update(t *testing.T) {
Files: []*file.ImageFile{
makeImageFileWithID(imageIdxWithGallery),
},
Organized: true,
CreatedAt: createdAt,
UpdatedAt: updatedAt,
GalleryIDs: []int{},
TagIDs: []int{},
PerformerIDs: []int{},
Organized: true,
CreatedAt: createdAt,
UpdatedAt: updatedAt,
},
false,
},
@@ -219,9 +226,12 @@ func Test_imageQueryBuilder_Update(t *testing.T) {
Files: []*file.ImageFile{
makeImageFileWithID(imageIdxWithTag),
},
Organized: true,
CreatedAt: createdAt,
UpdatedAt: updatedAt,
GalleryIDs: []int{},
TagIDs: []int{},
PerformerIDs: []int{},
Organized: true,
CreatedAt: createdAt,
UpdatedAt: updatedAt,
},
false,
},
@@ -232,9 +242,12 @@ func Test_imageQueryBuilder_Update(t *testing.T) {
Files: []*file.ImageFile{
makeImageFileWithID(imageIdxWithPerformer),
},
Organized: true,
CreatedAt: createdAt,
UpdatedAt: updatedAt,
GalleryIDs: []int{},
TagIDs: []int{},
PerformerIDs: []int{},
Organized: true,
CreatedAt: createdAt,
UpdatedAt: updatedAt,
},
false,
},
@@ -403,6 +416,9 @@ func Test_imageQueryBuilder_UpdatePartial(t *testing.T) {
Files: []*file.ImageFile{
makeImageFile(imageIdx1WithGallery),
},
GalleryIDs: []int{},
TagIDs: []int{},
PerformerIDs: []int{},
},
false,
},
@@ -596,7 +612,9 @@ func Test_imageQueryBuilder_UpdatePartialRelationships(t *testing.T) {
Mode: models.RelationshipUpdateModeRemove,
},
},
models.Image{},
models.Image{
GalleryIDs: []int{},
},
false,
},
{
@@ -2398,7 +2416,7 @@ func TestImageQuerySorting(t *testing.T) {
},
{
"file size",
"size",
"filesize",
models.SortDirectionEnumDesc,
-1,
-1,