Skip to content

Conversation

@maynetee
Copy link
Owner

@maynetee maynetee commented Feb 3, 2026

The search endpoint in app/api/messages.py (line 304-308) uses func.coalesce(Message.translated_text, literal('')).ilike(search_term) to handle NULL translated_text values. The COALESCE function wrapper prevents PostgreSQL from using the GIN trigram index (ix_messages_text_search) on the translated_text column, forcing a sequential scan on that predicate branch. The original_text ILIKE can use the index, but the translated_text branch cannot.

Mendel and others added 2 commits February 3, 2026 08:56
…y index usage

Created verify_search_index.py to verify GIN trigram index usage on search queries.
The script:
- Checks if ix_messages_text_search GIN index exists and is properly configured
- Verifies pg_trgm extension is enabled
- Runs EXPLAIN ANALYZE on search queries with ILIKE patterns
- Confirms index usage via Bitmap Index Scan (typical for GIN indexes)
- Verifies both original_text and translated_text can use the GIN index
- Validates that removing COALESCE allows index usage on translated_text

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@maynetee maynetee merged commit 5682d87 into main Feb 3, 2026
0 of 2 checks passed
@maynetee maynetee deleted the auto-claude/024-fix-search-coalesce-wrapper-preventing-gin-trigram branch February 3, 2026 14:56
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.

2 participants