Database Performance
Posted: Wed Jun 19, 2013 11:00 am
Nope. Just the defaults +/- 20 categories automatically imported from .XMP sidecar files (we have other DAMs on our LAN with which we do our cataloging). I didn't use the engine because I cannot - as I stated in other places, in order to really use an in-database organization, you must provide a best-in-class Compare Engine in order to assign in one pass ratings (mainly), colors and keywords (aka. categories). This is a dogma, an industry standard (for ex. see Lightroom, IDImager, ACDSee, FastStone Viewer, AfterShot Pro, Zoner Photo Studio, Photo Supreme - yes, I have worked with all these). IMHO, this should be the next step after optimizing the db and polishing the on-disk file management (organization).xnview wrote:Do you have a lot of categories? Images in categories? Tagged files?m.Th. wrote: When I open the program, it opens quite fast (the thumbnails were generated in the previous session), but for the first time when I want to change the tab of the Tree Pane from the 'Folders' to 'Categories' it freezes for a very long time
But we digress. Let's go back...
Well, nope.xnview wrote:Ok, i'm not expert in DBm.Th. wrote: Well, you have here SOME problems. In fact, at least in my use case of freezing (see my previous posts), the full table scan is (IMHO) triggered by 'Tag' field because you show in the Categories Tree the number of tagged photos (see Special Items\Tagged Files). That number is obtained by having a "Select count(*) from Images where Tag=1" or similar (for ex. "Select sum(tag) from Images"), isn't it? Also, in order to display the files you need to have a query (most probably a join with 'Datas') in which you have somewhere 'Where Tag=1', isn't it?![]()
Well, the above SQL queries (an aggregate on a non-indexed field, a search condition on a non-indexed field) triggers a full table scan. Hence the slowdown on big databases.
So you think that i must add, right?Code: Select all
CREATE UNIQUE INDEX Tags_idx ON Images(ImageID, Tag);

...and really doesn't matter that you aren't an expert in DB.


IMHO, you must do the following:
(after each command follows a short explanation)
(more explanations about why is this upon request)
(the SQL commands are written from top of my head. Perhaps the syntax isn't entirely correct)
Code: Select all
CREATE INDEX Tags_idx ON Images(Tag);
Code: Select all
Create Index Rating_idx on Images(Rating);
Code: Select all
Create Index Color_idx on Images(Color);
You have also two other columns in the same table - Size and ModifiedDate which, depending on their use, need also indexes. An interesting thing to note is the possibility to use Size field as a strong limiter to find duplicates. But about this, in the future.
As an aside, in TagsTree table you have 2(two) identical indexes - the one is the autoindex created automatically by issuing
Code: Select all
UNIQUE (ImageID, TagID)
Code: Select all
CREATE INDEX TagsTree_idx ON TagsTree(ImageID,TagID);
Also, in Tags table you need for sure an index on 'ID' field - something like this:
Code: Select all
Create Index Tags_ID_idx on Tags(ID);
Code: Select all
Create Index Tags_ParentID_idx on Tags(ParentID);
Code: Select all
UNIQUE (Label, ParentID)
To all of you guys, feel free to comment till I'll come back with more analysis.
Also, some questions for Pierre: (perhaps I could help further)
1. 'Datas' table has the thumbnails in it, right?
1a. Then what's the purpose of 'Created' and 'Size' fields?
2. 'Extra' table - for what is it?
3. 'ImagesInfo' table - I strongly suspect that we can optimize this. Where do you use it? Also, at least, for me the 'Format' column is quite odd. You simply put the extension there?
Btw, in Images table the Meta field has the EXIF info, isn't it?