Prepare search deletions without caching them #180

Merged
jcoffey-dev merged 1 commits from fix/unindex-statement-cache into main 2026-10-08 23:07:32 +00:00
Owner

Backlog Tier 3. The index task removes deleted documents with one query per batch: WHERE (accid = $1 AND (docid = $2 OR docid = $3 ...)) OR ..., one term per document. Every distinct batch shape is new SQL text, and PostgresStore::unindex used prepare_cached. deadpool-postgres' statement cache has no limit, so each connection kept a prepared statement for every shape it ever saw, in inbuxa's memory and as a prepared statement in its PostgreSQL backend, until the connection closed. With a 40-connection pool on each of three nodes that grows for the life of the process.

Both the plain DELETE and the chunked fallback are now prepared with prepare (one extra round trip, on a maintenance path) and closed when the statement drops. Search queries are untouched: their values are parameters, so their shapes are bounded by the filter structure.

Store and IMAP suites pass on PostgreSQL.

Backlog Tier 3. The index task removes deleted documents with one query per batch: `WHERE (accid = $1 AND (docid = $2 OR docid = $3 ...)) OR ...`, one term per document. Every distinct batch shape is new SQL text, and `PostgresStore::unindex` used `prepare_cached`. deadpool-postgres' statement cache has no limit, so each connection kept a prepared statement for every shape it ever saw, in inbuxa's memory and as a prepared statement in its PostgreSQL backend, until the connection closed. With a 40-connection pool on each of three nodes that grows for the life of the process. Both the plain DELETE and the chunked fallback are now prepared with `prepare` (one extra round trip, on a maintenance path) and closed when the statement drops. Search queries are untouched: their values are parameters, so their shapes are bounded by the filter structure. Store and IMAP suites pass on PostgreSQL.
jcoffey-dev added 1 commit 2026-10-08 22:59:19 +00:00
Prepare search deletions without caching them
ci / fork-checks (pull_request) Skipped
ci / build (pull_request) Skipped
github/ci (branch) GitHub Actions
ci / github (pull_request) Successful in 7m45s
fa87b86f3a
The index task deletes a batch of documents with one `docid = $n` term
per document, so every batch shape is new SQL text. The connection's
statement cache has no limit and kept each of them, on both sides, for
the life of the connection. Deletions are maintenance; they are now
prepared for the one use, and the statement is closed after it.
jcoffey-dev merged commit d0ee50b62f into main 2026-10-08 23:07:32 +00:00
jcoffey-dev deleted branch fix/unindex-statement-cache 2026-10-08 23:07:32 +00:00
Sign in to join this conversation.