Skip to content

Fix intermittent failure in the person search index plan test - #236

Merged
atomantic merged 1 commit into
mainfrom
fix/search-plan-stats
Oct 21, 2026
Merged

atomantic merged 1 commit into
mainfrom
fix/search-plan-stats

Conversation

@atomantic

Copy link
Copy Markdown
Owner

The main branch CI run after #232 failed in tests/integration/db/postgresSearch.spec.ts ("uses the GIN document index for selective prefixes on representative data"): the plan showed a sequential scan of person estimated at 5 rows joined to person_search by primary key, so idx_person_search_document never appeared.

Cause: the test inserts 12,000 people but only analyzes person_search. When autovacuum has already analyzed person while it was small, the planner keeps the stale row estimate and prefers driving from person. I reproduced this locally by analyzing person before the insert (the test then fails every time) and confirmed that analyzing both tables after the insert makes it pass.

Validated against a throwaway PostgreSQL 17 instance: the full integration suite passes (182 tests).

The GIN index plan test only analyzed person_search after inserting 12,000
fixture people. If autovacuum had analyzed person earlier while it was
small, the planner still believed person held a handful of rows, drove the
join from a sequential scan of person and never used the GIN index. That
made the integration suite fail intermittently on main. Analyzing both
tables makes the plan depend on the fixture data, not on autovacuum timing.
@atomantic
atomantic merged commit f32cb85 into main Oct 21, 2026
4 checks passed
@atomantic
atomantic deleted the fix/search-plan-stats branch October 21, 2026 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant