Comment 5 for bug 1902313

Revision history for this message
Charles Haley (cbhaley) wrote :

@kovid, I agree that building a cache isn't the way to go. It a) is easy to get wrong, and b) might actually make performance worse because of cache management.

Instead I am thinking about adding a method "has_annotations" that produces in effect a yes/no answer on whether any format of the book has annotations. It would run the query
    'SELECT count(id) FROM annotations WHERE book=?', (book_id,)
This query is run entirely from annot_idx so in effect it is a memory lookup. No result set is generated. I ran the SQLite query analyzer which confirmed that the query uses only the index.

I just realized that this could be "annotations_count" at no extra query cost. I am not sure whether this is useful, but why not support providing the extra information.

My concern is that even with the memory-based index query the performance won't be acceptable. However, given that some people use formats_modtimes() in columns indicates that they are willing to pay what it takes to get the answer they want. It is after all their choice.

What do you think?