Sqlite DB File is too huge....?
I've been creating a dictionary file that contains 85000 records with Sqlite and QT. the file of sqlite is too huge, it's 134MB, and another dictionary like MDic DB have same data that created with sqlite and same records is 10 MB!
query.exec("PRAGMA journal_mode = MEMORY");
query.exec("PRAGMA synchronous开发者_StackOverflow = OFF");
Dic_entry DictionaryEntry = DictionaryInstance.readEntry();
QString definition, headword, displayedHeadWord;
query.exec("BEGIN Transaction");
int Count = 0;
while(!DictionaryEntry.headword.empty())
{
definition = QString::fromStdString(DictionaryEntry.definition);
definition.replace("'", "''");
headword = QString::fromStdString(DictionaryEntry.headword);
headword.replace("'", "''");
displayedHeadWord = QString::fromStdString(DictionaryEntry.displayedHeadword);
displayedHeadWord.replace("'", "''");
string strQuery = "INSERT INTO Dictionary_Words([Definition], [HeadWord], [DisplayedHeadWord]) "
"values('"
+ definition.toStdString() + "', '"
+ headword.toStdString() + "', '"
+ displayedHeadWord.toStdString()
+ "')";
query.exec(QString::fromStdString(strQuery));
if(Count == 200)
{
query.exec("COMMIT TRANSACTION");
Count = 0;
}
Count++;
DictionaryEntry = DictionaryInstance.readEntry();
}
query.exec("End Transaction");
query.exec("CREATE INDEX HW_idx ON [Dictionary_Words](HeadWord)");
query.exec("CREATE INDEX Def_idx ON [Dictionary_Words](Definition)");
query.exec("CREATE INDEX DHW_idx ON [Dictionary_Words](DisplayedHeadword)");
query.exec("PRAGMA auto_vacuum=FULL");
db.close();
Please help me that how can i reduce my SQlite DB file
I have no way of proving it, but I suspect the indexes are the cause of the trouble. Indexes can take up a huge amount of space, and you've got three of them. Try it without them and see if the access is still acceptably fast; the database size should be much smaller that way.
精彩评论