Skip to content

Conversation

@hf-kklein
Copy link
Contributor

@hf-kklein hf-kklein commented Oct 21, 2025

because

... WHERE LOWER(haystack_column) LIKE 'needle'

doesn't use the index

and

... WHERE haystack_column LIKE 'needle'

is only case-insensitive by default for ASCII characters. See https://sqlite.org/optoverview.html#the_like_optimization

…terialized` for faster search

because
```sql
... WHERE LOWER(haystack_column) LIKE 'needle'
```
doesn't use the index

and
```sql
... WHERE haystack_column LIKE 'needle'
```

is only case-insensitive for ASCII characters. See https://sqlite.org/optoverview.html#the_like_optimization
@hf-kklein hf-kklein changed the title chore(sql): Add COLLATE NOCASE to some indexes on `ahb_hierarchy_ma… chore(sql): Add COLLATE NOCASE to some indexes on ahb_hierarchy_materialized for faster search Oct 21, 2025
@hf-kklein hf-kklein changed the title chore(sql): Add COLLATE NOCASE to some indexes on ahb_hierarchy_materialized for faster search perf(sql): Add COLLATE NOCASE to some indexes on ahb_hierarchy_materialized for faster search Oct 21, 2025
hf-kklein added a commit to Hochfrequenz/ahb-tabellen that referenced this pull request Oct 21, 2025
… index)

maybe we need to add `COLLATE NOCASE` to the where clause, idk...

see: Hochfrequenz/xml-fundamend-python#193
@hf-kklein hf-kklein requested a review from Copilot October 21, 2025 08:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR optimizes search performance on the ahb_hierarchy_materialized table by adding COLLATE NOCASE to string column indexes. This enables case-insensitive LIKE queries to utilize indexes without requiring LOWER() function calls, which prevent index usage in SQLite.

Key changes:

  • Added COLLATE NOCASE to 9 text-based indexes on columns used for search operations
  • Enables case-insensitive search across all Unicode characters (not just ASCII) while maintaining index performance

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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.

3 participants