mirror of
https://github.com/ankitects/anki.git
synced 2025-11-14 08:37:11 -05:00
add an index for modified to speed up sync.summary()
testing indicates this can produce a 2x performance improvement on lastSync=0, and much more for partial syncs
This commit is contained in:
parent
fe97616ecd
commit
3491a5e378
1 changed files with 12 additions and 4 deletions
16
anki/deck.py
16
anki/deck.py
|
|
@ -69,7 +69,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 = 56
|
DECK_VERSION = 57
|
||||||
|
|
||||||
deckVarsTable = Table(
|
deckVarsTable = Table(
|
||||||
'deckVars', metadata,
|
'deckVars', metadata,
|
||||||
|
|
@ -3750,6 +3750,13 @@ create index if not exists ix_cards_typeCombined on cards
|
||||||
deck.s.statement("""
|
deck.s.statement("""
|
||||||
create index if not exists ix_cards_relativeDelay on cards
|
create index if not exists ix_cards_relativeDelay on cards
|
||||||
(relativeDelay)""")
|
(relativeDelay)""")
|
||||||
|
# index on modified, to speed up sync summaries
|
||||||
|
deck.s.statement("""
|
||||||
|
create index if not exists ix_cards_modified on cards
|
||||||
|
(modified)""")
|
||||||
|
deck.s.statement("""
|
||||||
|
create index if not exists ix_facts_modified on facts
|
||||||
|
(modified)""")
|
||||||
# priority - temporary index to make compat code faster. this can be
|
# priority - temporary index to make compat code faster. this can be
|
||||||
# removed when all clients are on 1.2, as can the ones below
|
# removed when all clients are on 1.2, as can the ones below
|
||||||
deck.s.statement("""
|
deck.s.statement("""
|
||||||
|
|
@ -4300,10 +4307,11 @@ update fieldModels set quizFontFamily = 'Arial' where not quizFontFamily
|
||||||
or quizFontFamily is null""")
|
or quizFontFamily is null""")
|
||||||
deck.version = 55
|
deck.version = 55
|
||||||
deck.s.commit()
|
deck.s.commit()
|
||||||
if deck.version < 56:
|
if deck.version < 57:
|
||||||
# add an index for priority
|
# add an index for priority & modified
|
||||||
DeckStorage._addIndices(deck)
|
DeckStorage._addIndices(deck)
|
||||||
deck.version = 56
|
deck.s.statement("analyze")
|
||||||
|
deck.version = 57
|
||||||
deck.s.commit()
|
deck.s.commit()
|
||||||
# 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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue