Files
calibre-web/cps
alcibiadesc a3b5d2eac7 Optimize search performance for large libraries
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.
2025-11-01 19:48:16 +01:00
..
2024-11-04 21:20:34 +01:00
2025-03-30 12:03:12 +02:00
2025-09-08 12:05:59 +02:00
2025-04-12 03:59:32 +08:00
2025-07-04 20:22:11 +02:00
2024-11-23 15:46:20 +01:00
2022-05-22 12:49:00 +01:00
2024-09-07 20:07:45 +02:00
2024-11-26 06:13:18 +01:00
2022-05-21 21:52:59 +01:00
2025-03-23 09:18:48 +01:00
2025-09-08 12:05:59 +02:00
2024-06-20 19:12:46 +02:00
2023-01-21 15:23:18 +01:00
2022-04-30 10:17:41 +02:00
2024-07-02 20:53:08 +02:00
2025-09-08 12:05:59 +02:00
2024-11-23 15:46:20 +01:00
2025-03-30 12:03:12 +02:00
2024-12-13 18:03:14 +01:00
2025-03-23 15:12:06 +01:00
2024-11-23 15:46:20 +01:00
2024-07-29 20:08:17 +02:00
2024-07-15 19:38:54 +02:00
2025-03-30 12:03:12 +02:00
2024-12-07 07:27:00 +01:00
2025-03-30 12:03:12 +02:00
2024-10-28 16:16:28 +01:00
2024-08-21 19:25:50 +02:00
2025-03-30 12:03:12 +02:00
2024-11-11 18:46:07 +01:00
2025-03-30 12:03:12 +02:00