Books.atom_timestamp returned Books.timestamp (date added), which is
set at import and never changes. OPDS clients use atom:updated to
decide whether a book has changed on the server, so cover swaps,
metadata edits, and any other post-import change were invisible to
sync clients; they would keep serving the stale cover and title
until a manual refresh.
Atom RFC 4287 defines updated as "the most recent instant in time
when an entry or feed was modified", and Calibre already tracks that
field as last_modified, bumping it on every metadata and cover edit.
Switching the property to return last_modified (with a fallback to
timestamp when last_modified is NULL) aligns Calibre-Web's behaviour
with the Atom contract.
This change only affects the OPDS feed's atom:updated element. Kobo
sync uses its own last_modified comparison path, so it is unaffected.
- Add FTS5 table existence check to avoid log spam on non-FTS databases
- Escape FTS5 special characters (quotes) to prevent query errors
- Wrap FTS5 search terms in quotes for phrase matching accuracy
- Improve logging: change author ordering debug to warning for visibility
- Add comment explaining author_sort data issues
These changes improve robustness and security without affecting performance.
This commit introduces several performance optimizations to the search
system, significantly reducing query times for large Calibre libraries.
Key improvements:
1. FTS5 Integration
- Added FTS5 full-text search support with automatic fallback
- Uses indexed search when available, providing sub-second results
- Gracefully degrades to traditional search if FTS5 is unavailable
2. Query Optimization
- Replaced expensive .any() subqueries with efficient JOIN-based
subqueries for tags, series, authors, and publishers
- Reduced SQL complexity and improved query planning
- Added selectinload() for authors to prevent N+1 query problems
3. LIMIT+1 Pattern
- Implemented LIMIT+1 estimation pattern in get_search_results()
- Avoids expensive COUNT(*) operations on large result sets
- Provides fast pagination without sacrificing accuracy
4. Author Ordering Optimization
- Replaced nested database queries with O(1) dictionary lookups
- Eliminated N+1 query anti-pattern in order_authors()
- Reduced author sorting from O(n²) to O(n) complexity
Performance Impact:
In testing with a library of 129,000+ books, these optimizations reduced
search times from 3-9 seconds to 85-330ms, achieving 89-97% improvement
across different search types.
The changes maintain backward compatibility and include fallbacks for
environments without FTS5 support.
Cookies are saved in database for better Invalidation
Cookies expiry date is saved in database for further deletion (missing)
Database conversion is missing