Databases · Middle · Question 4 of 75
Why can't a normal B-tree index speed up WHERE name LIKE '%son'?
- 1
LIKEnever uses indexes - 2The index only stores numbers
- ✓Correct answer: With a leading wildcard the beginning of the value is unknown, so the sorted index can't narrow the search
Explanation
LIKE 'son%' can use a B-tree (with a suitable operator class). For substring or fuzzy search use a trigram GIN index (pg_trgm) or full-text search.