Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 02-03-2018, 02:16 PM   #1
ilovejedd
hopeless n00b
ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.
 
ilovejedd's Avatar
 
Posts: 5,110
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
Restored metadata.db and original metadata.db different sizes?

Did something stupid with my library and instead of restoring metadata.db from my primary backup, I accidentally overwrote it with the bad metadata.db. I did a database restore (from opf, which thankfully hadn't updated yet).

The restored metadata.db is just 4MB while the original metadata.db was 20MB. A quick spot check seems to show the books and metadata are correct albeit by no means was the verification exhaustive. What could cause the disparity in file size and what information might be missing from the restored database?
ilovejedd is offline   Reply With Quote
Old 02-03-2018, 05:04 PM   #2
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,706
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Relational databases accumulate dross over time, mainly due to deletions and replacements, so they need to be optimised occasionally - aka as 'vacuuming' Ψ²

By rebuilding it you have eliminated the dross. FYI - the Check database function does a 'vacuum' as its first step.

BR
BetterRed is offline   Reply With Quote
Advert
Old 02-03-2018, 07:26 PM   #3
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,020
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by BetterRed View Post
Relational databases accumulate dross over time, mainly due to deletions and replacements, so they need to be optimised occasionally - aka as 'vacuuming' Ψ²

By rebuilding it you have eliminated the dross. FYI - the Check database function does a 'vacuum' as its first step.

BR
I agree with all you said. But...

not the 4 times bigger part.
Everything (in the defining tables) would have to have been redefined, many times to get that huge.

I DO recommend 'quarterly' housekeeping (Calibre Maintenance) on any Library with frequent Metadata defining changes. FWIW in a RDB you define an Author: J.D. Robb. You assign that defined author INDEX (not visible to a normal user) to a book entry. , The same is true for all column types except Comments. That is a BLOB.
theducks is offline   Reply With Quote
Old 02-03-2018, 07:34 PM   #4
ilovejedd
hopeless n00b
ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.
 
ilovejedd's Avatar
 
Posts: 5,110
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
I run calibredb check_library everytime I backup so the original metadata.db has already been vacuumed (from 27MB to 20MB, iirc).

I actually created a copy of the library and put the bad metadata.db. There were just some tags changed between bad and original, the metadata.db sizes are really close. Vacuuming that gave me just ~100KB reduction.

I really think something else was lost with the restore.

Last edited by ilovejedd; 02-03-2018 at 07:36 PM.
ilovejedd is offline   Reply With Quote
Old 02-03-2018, 08:53 PM   #5
jhowell
Grand Sorcerer
jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.
 
jhowell's Avatar
 
Posts: 7,062
Karma: 91577715
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
Some plugins store library-specific data in the database.
jhowell is offline   Reply With Quote
Advert
Old 02-03-2018, 10:37 PM   #6
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,706
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
@theducks - I overlooked the dimensions of the issue. But I have done a 'vacuum' on a database that reduced its size by 90%, admittedly that was a high volume TP application for an investment bank using Oracle on a Vaxen cluster. My predecessor was too scared to do any housekeeping of that sort, so it had been churning away 365*24*7 for several years :lol:

Quote:
Originally Posted by jhowell View Post
Some plugins store library-specific data in the database.
I have a vague recollection of a plugin that shovelled the entire text of books into a comments like custom column so it could do fast searches. It may not have been a 'known' plugin (i.e. with an entry in the Index) but one that someone asked me to test.

If you remove a plugin, then it won't remove its library specific data from metadata.db (or its global data from the config plugins directory). The Job Spy plugin has a tool to remove data left behind in library databases by defunct plugins.

BR
BetterRed is offline   Reply With Quote
Old 02-04-2018, 12:24 AM   #7
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,318
Karma: 27111242
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
There are many thing in the db that a restore will not restore. Plugin data, book specific conversion settings, etc.

A restore is basically designed to restore only your book metadata, as that is the most precious thing. A restore should really be a last resort thing to do if you dont have backups.

And you can often recover a bad sqlite db by dumping it to sql and using the sql to re-create it, you might need to manually edit the sql a little to fix errors.
kovidgoyal is offline   Reply With Quote
Old 02-04-2018, 02:21 AM   #8
ilovejedd
hopeless n00b
ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.
 
ilovejedd's Avatar
 
Posts: 5,110
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
Quote:
Originally Posted by kovidgoyal View Post
There are many thing in the db that a restore will not restore. Plugin data, book specific conversion settings, etc.

A restore is basically designed to restore only your book metadata, as that is the most precious thing. A restore should really be a last resort thing to do if you dont have backups.

And you can often recover a bad sqlite db by dumping it to sql and using the sql to re-create it, you might need to manually edit the sql a little to fix errors.
Thanks! Looks like the conversion settings (for 4,000+ books) was the culprit. I always do bulk conversions so I never realized that per book conversion settings were getting stored in metadata.db. I'll need to make a habit of deleting those via bulk metadata edit. I do versioned backups of metadata.db (sometimes up to 5 times in one day) so that should save quite a bit of space.

Yep, the metadata is the important part. The database wasn't actually bad or corrupted at all. I just did something stupid and accidentally changed tags that I didn't mean to change and restoring the old tags was priority. Anyway, I actually do have copies of the library in several flash drives that I forgot in the office. I just didn't want to wait until Monday to test out some things so I tried out the Restore database function and I'm happy to report it worked wonderfully. I'll nuke this library and restore from backup but in the meantime, I was able to test a bunch of regex stuff for search and replace, and MCS as well as templates for save to disk.
ilovejedd is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calibre fills automatically title and author metadata in books without any metadata? thosedays Library Management 5 10-28-2016 03:33 PM
Coping with huge discrepancies between original and restored database Beanxx Library Management 5 07-27-2015 04:23 PM
Regarding using metadata objects in identify method of metadata download plugin api aprekates Development 1 07-06-2014 03:35 AM
Save the Metadata to the Libary files/change filename to the Metadata RyuujiTakasu Calibre 10 03-19-2014 02:01 PM
Can the K2 original firmware be restored? hmemcpy Kindle Developer's Corner 0 05-06-2009 12:57 AM


All times are GMT -4. The time now is 01:08 PM.


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