ig3 / anki-limitnew

Limit the number of new cards in Anki
MIT License
3 stars 0 forks source link

Slow startup #9

Open GrimPixel opened 2 years ago

GrimPixel commented 2 years ago

Anki normally starts within 2 seconds, With this add-on, it takes an extra 13 seconds. Is it possible to accelerate it?

ig3 commented 2 years ago

Most of the time is in the database queries.

Only enabling the limits you care about will help. There are per-deck limits and total limits. If you disable the per-deck limits, that will probably help, assuming your needs are met by the total limits alone. If per-deck limits are enabled, there are database queries for each deck.

Rather than a query per deck, it would probably be possible to consolidate the queries to a single query that returned the results required for all decks in a single query. This might be quicker overall and probably not too much more complicated to implement.

Caching query results would help, though not much with startup.

I haven't used Anki for about a year now, so I don't know how the current version behaves. The scheduler and overall implementation were evolving rapidly when I was last using it. As I don't use Anki, I'm not very motivated to do more work on this add-on myself, but feel free try profiling and improving the database queries if you like.