Skip to content

Commit

Permalink
fix: add index to speed up download with >10k notes DB
Browse files Browse the repository at this point in the history
fix #14
  • Loading branch information
vzhd1701 committed Feb 14, 2022
1 parent 0430bfd commit 2dbb599
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion evernote_backup/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
API_DATA = b"Q0sJVEtPDWt7bmg2YnhtY344enZlMSRsPjxtaTI7P2Q0PTRhNWc="
API_DATA_OAUTH = b"eW91c3V3dn9mYjF2az48bzM7Pm4wZzdlZzpk"

CURRENT_DB_VERSION = 4
CURRENT_DB_VERSION = 5
9 changes: 9 additions & 0 deletions evernote_backup/note_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class NoteForSync(NamedTuple):
ON notes(title COLLATE NOCASE);
CREATE INDEX IF NOT EXISTS idx_notebooks_linked
ON notebooks_linked(guid, notebook_guid);
CREATE INDEX IF NOT EXISTS idx_notes_raw
ON notes(guid) WHERE raw_note IS NULL;
"""


Expand Down Expand Up @@ -131,6 +133,13 @@ def upgrade_db(self, db_version: int) -> None:
" ON notebooks_linked(guid, notebook_guid);"
)

if db_version < 5:
with self.db as con4:
con4.execute(
"CREATE INDEX IF NOT EXISTS idx_notes_raw_null"
" ON notes(guid) WHERE raw_note IS NULL;"
)

self.config.set_config_value("DB_VERSION", str(CURRENT_DB_VERSION))

if need_resync:
Expand Down

0 comments on commit 2dbb599

Please sign in to comment.