remove some old indices

This commit is contained in:
Damien Elmes 2011-01-13 19:21:40 +09:00
parent 0b07707e68
commit 9b7a55d964

View file

@ -72,7 +72,7 @@ SEARCH_FIELD = 6
SEARCH_FIELD_EXISTS = 7 SEARCH_FIELD_EXISTS = 7
SEARCH_QA = 8 SEARCH_QA = 8
SEARCH_PHRASE_WB = 9 SEARCH_PHRASE_WB = 9
DECK_VERSION = 63 DECK_VERSION = 64
deckVarsTable = Table( deckVarsTable = Table(
'deckVars', metadata, 'deckVars', metadata,
@ -3807,14 +3807,6 @@ create index if not exists ix_facts_modified on facts
deck.s.statement(""" deck.s.statement("""
create index if not exists ix_cards_priority on cards create index if not exists ix_cards_priority on cards
(priority)""") (priority)""")
# failed cards, review early - obsolete
deck.s.statement("""
create index if not exists ix_cards_duePriority on cards
(type, isDue, combinedDue, priority)""")
# check due - obsolete
deck.s.statement("""
create index if not exists ix_cards_priorityDue on cards
(type, isDue, priority, combinedDue)""")
# average factor # average factor
deck.s.statement(""" deck.s.statement("""
create index if not exists ix_cards_factor on cards create index if not exists ix_cards_factor on cards
@ -4386,6 +4378,19 @@ update fieldModels set editFontSize = 20 where editFontSize = ''
or editFontSize is null""") or editFontSize is null""")
deck.version = 63 deck.version = 63
deck.s.commit() deck.s.commit()
if deck.version < 64:
# remove old static indices, as all clients should be libanki1.2+
for d in ("ix_cards_duePriority",
"ix_cards_priorityDue"):
deck.s.statement("drop index if exists %s" % d)
# remove old dynamic indices
for d in ("intervalDesc", "intervalAsc", "randomOrder",
"dueAsc", "dueDesc"):
deck.s.statement("drop index if exists ix_cards_%s" % d)
deck.s.execute("analyze")
deck.version = 64
deck.s.commit()
# note: we keep the priority index for now
# executing a pragma here is very slow on large decks, so we store # executing a pragma here is very slow on large decks, so we store
# our own record # our own record
if not deck.getInt("pageSize") == 4096: if not deck.getInt("pageSize") == 4096: