Skip to content

Instantly share code, notes, and snippets.

@riceissa
Last active Nov 22, 2019
Embed
What would you like to do?
Resetting ease factor for a deck in Anki

Personal background

A while ago I changed the default ease factor for my math problems deck to something like 160% (from the default of 250%), probably because I was worried that if my card intervals became too large too quickly, I would have too many problems that I didn't know how to do well. Instead what ended up happening was that I would get the same problems over and over again, and the deck became less fun to the point where I kept avoiding reviewing it (currently I have 43 due cards, which is a large number because each problem takes up to 30 minutes to complete).

After researching Anki deck options, it became clear that the problem was the ease factor for the deck. (At first I didn't even realize the problem was due to a setting I had changed; I just wanted to figure out how the spacing algorithm worked so that I could make the intervals larger.) But apparently the way Anki works is that it stores the ease factor for each card as an absolute value (rather than relative to the default ease factor for the deck). So changing the default ease factor for the deck after the fact does not reschedule all the cards in the deck with the "wrong" (too low) ease factor. Instead, one must go into the Anki database and manually change the ease factor for the problematic cards.

Locating the Anki database

On Ubuntu, the deck was at /home/issa/.local/share/Anki2/User 1.

Sqlite commands

I would close Anki before opening the sqlite database from the terminal.

Find the deck ID of the problematic cards

(Finding the deck ID isn't necessary if you want to fix the ease factor regardless of which deck it is in, but in my case all the problematic cards were in a single deck, so I wanted to find what its ID was.)

The Anki database layout stores the contents of the card in the notes deck (but not the cards deck) and the deck ID of the cards in the cards deck (but not the notes deck), so we must use a join in the query.

did means "deck ID", and flds seems to be short for "fields" and contains the actual card content.

There are multiple ways to do this:

  • Use limits and slowly filter out the wrong decks. Use the following query:

    select did, flds from notes inner join cards on cards.nid = notes.id limit 5;
    

    This will show the first five cards and their deck ID. If the cards are from the right deck, record that deck ID. If not, modify the query to give conditions like did != 22222222222222 where 22222222222222 is the wrong deck ID, to filter out that deck. Keep going until you find the right deck ID.

  • Search for text in some card in the deck.

    select did, flds from notes inner join cards on cards.nid = notes.id where flds like '%text you want to search for%';
    

View the ease factor for the deck

Once you know the deck ID, you can search for the ease factor of cards in that deck. If the deck ID is 1111111111111, the following query will list the first 100 cards in the deck and show their ease factor (and deck ID).

select factor, did from notes inner join cards on cards.nid = notes.id where did = 1111111111111 limit 100;

Anki stores the ease factor with an extra zero, so e.g. 2500 means 250%.

(In my case, I was looking for lots of ease factors around 1600, which I indeed found.)

Update ease factor

update cards set factor = 2500 where did = 1111111111111 and factor between 1300 and 1900;

Some of my cards had an ease factor near 2500 (because they were first reviewed after I had reset the settings for the deck), so I didn't want to change those; hence the between condition.

Verify

Now you can reopen Anki and go to the browser for the deck in question. Right click to get the ease factor to show up in the column, and verify that the ease factor for the problematic cards are all at 250%.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment