Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre Companion

Notices

Reply
 
Thread Tools Search this Thread
Old 08-11-2014, 08:07 AM   #31
HarryT
eBook Enthusiast
HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.
 
HarryT's Avatar
 
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?
HarryT is offline   Reply With Quote
Old 08-11-2014, 08:16 AM   #32
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,450
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by HarryT View Post
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?
Stock SQL. Since you seem to know this stuff, here are the statements.

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 + ";");
V15 to V16: add the new date_added_to_cc column.
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));
One thing occurs to me. When I developed the 14->15 upgrade I checked to see if the indices attached to the original table remained after the rename. Perhaps I missed something and they were dropped. If so then that would account for the loss of performance, turning every query into a full table scan.

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.
chaley is offline   Reply With Quote
Advert
Old 08-11-2014, 08:34 AM   #33
HarryT
eBook Enthusiast
HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.
 
HarryT's Avatar
 
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.
HarryT is offline   Reply With Quote
Old 08-11-2014, 08:48 AM   #34
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
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
Note the first QUERY PLAN line. It is using a scan.

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
Now the first query in the plan uses an index. In addition, the second part of the query now uses a permanent index instead of an automatic one that will be dropped from time to time.

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.
chaley is offline   Reply With Quote
Old 08-11-2014, 08:52 AM   #35
HarryT
eBook Enthusiast
HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.
 
HarryT's Avatar
 
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.
HarryT is offline   Reply With Quote
Advert
Old 08-13-2014, 11:25 AM   #36
kaufman
Calibre Companion Fanatic
kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.
 
kaufman's Avatar
 
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.
kaufman is offline   Reply With Quote
Old 08-13-2014, 12:39 PM   #37
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,450
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by kaufman View Post
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.
Confirmed the bug in 3.4.2, and confirmed that it has already gone away in my development version.
Quote:
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".
I had no intention of allowing someone to hide "standard" information. I was going to permit adding more information. I am quite sure that I will keep that point of view.

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.
chaley is offline   Reply With Quote
Old 08-13-2014, 12:43 PM   #38
kaufman
Calibre Companion Fanatic
kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.
 
kaufman's Avatar
 
Posts: 873
Karma: 1088610
Join Date: Nov 2006
Device: Galaxy Note 4, Kindle Voyage
Quote:
Originally Posted by chaley View Post
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.
That works for me. Thanks.
kaufman is offline   Reply With Quote
Old 08-13-2014, 03:55 PM   #39
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,450
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by chaley View Post
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.
I ended up doing it on a sort-by-sort basis.
Click image for larger version

Name:	Clipboard01.jpg
Views:	268
Size:	37.7 KB
ID:	126800

Also, I have added changing the order in the grouping drawer and the sort menu.
Attached Thumbnails
Click image for larger version

Name:	Clipboard03.jpg
Views:	230
Size:	38.3 KB
ID:	126801   Click image for larger version

Name:	Clipboard04.jpg
Views:	237
Size:	46.6 KB
ID:	126802  
chaley is offline   Reply With Quote
Old 08-13-2014, 04:03 PM   #40
kaufman
Calibre Companion Fanatic
kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.
 
kaufman's Avatar
 
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.
kaufman is offline   Reply With Quote
Old 08-13-2014, 04:15 PM   #41
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,450
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by kaufman View Post
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?
It won't be in 3.4.3. That is going to be a bug fix release, probably made available in early Sept.

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:
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.
I actually worry about that.

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.
chaley is offline   Reply With Quote
Old 08-13-2014, 04:36 PM   #42
kaufman
Calibre Companion Fanatic
kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.kaufman ought to be getting tired of karma fortunes by now.
 
kaufman's Avatar
 
Posts: 873
Karma: 1088610
Join Date: Nov 2006
Device: Galaxy Note 4, Kindle Voyage
Quote:
Originally Posted by chaley View Post
I actually worry about that.
Well, I wouldn't worry too much. I say you have no credibility, but the truth is that each time you do it I am pleasantly surprised.
kaufman is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 08:58 AM.


MobileRead.com is a privately owned, operated and funded community.