![]() |
#31 |
eBook Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 85,556
Karma: 93383099
Join Date: Nov 2006
Location: UK
Device: Kindle Oasis 2, iPad Pro 10.5", iPhone 6
|
Wow - that's an amazing improvement! There does seem to be something that's being seriously messed up by the database update in the recent release, by the sound of it. Do you just send it SQL commands to update the database schema? "ALTER DATABASE...", etc?
|
![]() |
![]() |
![]() |
#32 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,450
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
V14 to V15: remove a constraint on a column. SQLite cannot do that with an ALTER TABLE so you must create a new table and copy the info. Code:
db.execSQL("create table if not exists " + "newCats" + " (" + C.KEY_CAT_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + C.KEY_CAT_GROUP + " TEXT, " + C.KEY_CAT_NAME + " TEXT, " + C.KEY_CAT_NAME_SORT + " TEXT COLLATE LOCALIZED, " + C.KEY_CAT_FL + " TEXT COLLATE LOCALIZED);"); db.execSQL("INSERT INTO newCats SELECT * FROM " + C.TABLE_CATEGORIES + ";"); db.execSQL("DROP TABLE " + C.TABLE_CATEGORIES + ";"); db.execSQL("ALTER TABLE newCats RENAME TO " + C.TABLE_CATEGORIES + ";"); Code:
db.execSQL(buildQuery("ALTER TABLE", C.TABLE_BOOKS, "ADD COLUMN", C.KEY_DATE_ADDED_TO_CC, "TIMESTAMP;")); db.execSQL(buildQuery("UPDATE", C.TABLE_BOOKS, "SET", C.KEY_DATE_ADDED_TO_CC, "=", C.KEY_DATE_CHANGED)); I will build and populate a V3.3.6 install, upgrade it to V3.4.2, then do QUERY EXPLAIN to see if the indices are still in use. |
|
![]() |
![]() |
Advert | |
|
![]() |
#33 |
eBook Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 85,556
Karma: 93383099
Join Date: Nov 2006
Location: UK
Device: Kindle Oasis 2, iPad Pro 10.5", iPhone 6
|
There's certainly nothing obviously amiss with those SQL commands that I can see. An indexing issue does seem quite likely - with 3500 books in my database, a full table scan (especially if it's doing joins to other tables) could be very slow.
|
![]() |
![]() |
![]() |
#34 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,450
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
It is indeed almost certainly the (lack of) indices.
Here is the query plan after upgrade from V3.3.6 to V3.4.2. Code:
EXPLAIN QUERY PLAN FOR getAllBooks SELECT id FROM Categories , Books , cat_books_link WHERE cat_group =? AND cat_name =? AND cbl_category = cat_id AND id = cbl_book ORDER BY author_sort ASC,title_sort ASC,title_sort ASC ; QUERY PLAN getAllBooks: 0:0:0:SCAN TABLE Categories (~10000 rows) QUERY PLAN getAllBooks: 0:1:2:SEARCH TABLE cat_books_link USING AUTOMATIC COVERING INDEX (cbl_category=?) (~7 rows) QUERY PLAN getAllBooks: 0:2:1:SEARCH TABLE Books USING INTEGER PRIMARY KEY (rowid=?) (~1 rows) QUERY PLAN getAllBooks: 0:0:0:USE TEMP B-TREE FOR ORDER BY Here is the query plan for V3.4.2 after recreating the indices Code:
EXPLAIN QUERY PLAN FOR getAllBooks SELECT id FROM Categories , Books , cat_books_link WHERE cat_group =? AND cat_name =? AND cbl_category = cat_id AND id = cbl_book ORDER BY author_sort ASC,title_sort ASC,title_sort ASC ; QUERY PLAN getAllBooks: 0:0:0:SEARCH TABLE Categories USING INDEX cat_group_fl (cat_group=?) (~2 rows) QUERY PLAN getAllBooks: 0:1:2:SEARCH TABLE cat_books_link USING COVERING INDEX cbl_lines (cbl_category=?) (~10 rows) QUERY PLAN getAllBooks: 0:2:1:SEARCH TABLE Books USING INTEGER PRIMARY KEY (rowid=?) (~1 rows) QUERY PLAN getAllBooks: 0:0:0:USE TEMP B-TREE FOR ORDER BY There are similar examples with other queries. The categories table is large, one line per unique item (author, publisher, tag, etc). Scanning that table on a large database is certainly suboptimal. ![]() I will add a rebuild of the indices to the database vacuum function. I will also be sure to rebuild the indices on the next CC release. |
![]() |
![]() |
![]() |
#35 |
eBook Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 85,556
Karma: 93383099
Join Date: Nov 2006
Location: UK
Device: Kindle Oasis 2, iPad Pro 10.5", iPhone 6
|
Excellent - delighted to hear you've found the cause of the problem. It's probably not going to affect many people as badly as it affected me, because I have the very worst combination of factors: a large book library, and a VERY slow device with little RAM. As I noted in an earlier post, the performance of 3.4.2 on my Nexus 7 (a much, much faster CPU and a lot more RAM) is absolutely fine, with grouping nodes opening instantly.
|
![]() |
![]() |
Advert | |
|
![]() |
#36 |
Calibre Companion Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 873
Karma: 1088610
Join Date: Nov 2006
Device: Galaxy Note 4, Kindle Voyage
|
I have found a bug in 3.4.2.
There are three ways to do a sort: 1) Select the sort in the sort dialog. 2) Select a grouping with an autosort 3) Click on a link on the book details screen If you select a sort in the sort dialog, it does four things: 1) It changes the order of the books in the book list 2) It shows the current sort in the Grouping drawer 3) If you pop up the sort dialog, the sort will be checked 4) If you are doing a sort other then title or date It will show the sort key in the book list It appears that when sorting on a custom column, if you tap on the link in the book details screen or select a group with an autosort, it does 1 and 2, but not 3 and 4. I don't think it needs a release to fix it, but maybe for the next release. Note: Actually, now that I think about it, I actually would rather not see it anyhow. So if you do fix it, I will probably hide it in when you do "extended information in list view". Last edited by kaufman; 08-13-2014 at 11:32 AM. |
![]() |
![]() |
![]() |
#37 | ||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,450
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Quote:
What I will consider is an option not to display the sorted-by line in the book list. This would apply to all sorted-by lines, not to individual sorts. |
||
![]() |
![]() |
![]() |
#38 |
Calibre Companion Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 873
Karma: 1088610
Join Date: Nov 2006
Device: Galaxy Note 4, Kindle Voyage
|
|
![]() |
![]() |
![]() |
#39 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,450
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Also, I have added changing the order in the grouping drawer and the sort menu. |
|
![]() |
![]() |
![]() |
#40 |
Calibre Companion Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 873
Karma: 1088610
Join Date: Nov 2006
Device: Galaxy Note 4, Kindle Voyage
|
Thanks, that look great. If this going to be in an upcoming 3.4.3, or are you just starting with the changes for 3.5?
You should know that you have zero credibility with me when you say you aren't willing to do something, because typically after you say that, your next post is about how you did it already. |
![]() |
![]() |
![]() |
#41 | ||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,450
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Whether the new functions I am doing now will be 3.4.X or 3.5 I don't know. I can make an argument either way. Quote:
![]() This time it turned out to be the same amount of work to do an option per sort as a single option. I didn't see much point of doing the single option simply to be consistent. |
||
![]() |
![]() |
![]() |
#42 |
Calibre Companion Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 873
Karma: 1088610
Join Date: Nov 2006
Device: Galaxy Note 4, Kindle Voyage
|
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
First published book | AppleTree13 | Self-Promotions by Authors and Publishers | 0 | 10-04-2013 07:36 AM |
Published - Dates | bigbird1227 | Plugins | 4 | 08-21-2011 06:54 AM |
'Published date' and 'originally published date' | Arrghus | Calibre | 2 | 07-29-2011 12:43 AM |
Published Dates | bigbird1227 | Library Management | 7 | 06-10-2011 10:40 AM |
Date published | philandjan | Library Management | 1 | 06-02-2011 11:43 AM |