5.13.0 — 2026-10-14¶
← 5.14.0 | 5.12.1 → | ↑ 5.x series
Added¶
Adapters - SQLAlchemy¶
- Count threshold -
execute_search_queryaccepts a keyword-onlycount_threshold. The total is exact up to that many rows. Above it, PostgreSQL returns the planner estimate (EXPLAIN (FORMAT JSON)) instead of scanning every row. MySQL, SQLite and StarRocks still count exactly.- The estimate never falls below the rows already counted, and a query that cannot be estimated falls back to the exact count
- Count cache - With
COUNT_CACHE_ENABLED=truethe total of a search is cached forCOUNT_CACHE_TTL_SECONDS, so only the first page of a search runs aCOUNTand later pages reuse the total. The sync adapters usettl_cacheand the async adapters usealru_cache, so it needs thecacheextra. The cache is off by default, and a total can be stale for up to the TTL.
Configs - SQLAlchemy¶
- Count settings -
COUNT_CACHE_ENABLED(defaultfalse),COUNT_CACHE_TTL_SECONDS(default60),COUNT_CACHE_MAX_SIZE(default1000) andCOUNT_THRESHOLD(default unset, always exact) are added toSQLAlchemyConfigand to.env.examplefor the SQLAlchemy, MySQL, SQLite and StarRocks configs.
Changed¶
Adapters - SQLAlchemy¶
- Cheaper search totals -
execute_search_queryskips theCOUNTwhen there is no pagination or the first page is not full. Otherwise theCOUNTreads only the entity primary key and drops theORDER BY, so the database can answer from the primary key index. A query withDISTINCT,GROUP BY,HAVING,LIMIT,OFFSETorFETCHkeeps its own columns, because they change the row count. - Filter expressions -
_apply_filterbuilds its expressions from one module-level map instead of a dict of 15 lambdas on every call.IS_NOT_NULLusesis_not. - Shared helpers - The sync and async adapters share the entity type checks and the entity extraction of
execute_search_query, and_handle_db_exceptionlowers the error message once.
Tests¶
- Search totals - New scenarios in
atomic_transactions.featurecover totals across pages, which pages run aCOUNT,DISTINCT,GROUP BYandLIMITqueries, the exact and estimated totals around the threshold, the cache keys and TTL (sync and async) and every filter operation, with the rejection of a non-list value for list filters. They run on PostgreSQL, SQLite, MySQL and StarRocks.
Chore¶
- Search totals tutorial - New
SQLAlchemy Search Totalstutorial, linked from the PostgreSQL, MySQL, SQLite and StarRocks tutorials and from the adapters index.