Re:The state of full text search in PostgreSQL 12
by Mister_Snuggles on Monday February 03, 2020 @03:36PM
(#22228705)
You can also create an index on the result of the function[0].
[0] https://www.postgresql.org/docs/12/indexes-expressional.html
Re:The state of full text search in PostgreSQL 12
by irrational on Monday February 03, 2020 @04:14PM
(#22229185)
I forgot to include the index and it is too late to edit my comment.
CREATE INDEX index_name ON some_table (public.insensitive_query(NAME));
Re:The state of full text search in PostgreSQL 12
by cies on Monday February 03, 2020 @03:33PM
(#22228678)
> If you use a function like this, [each query] it will need to be run for every entry
Re:The state of full text search in PostgreSQL 12
by rzwitserloot on Monday February 03, 2020 @04:12PM
(#22229169)
No; if you create an index for the item: `insensitiveQuery(some_table.name)` and you then attempt to run: `SELECT * FROM some_table WHERE insensitiveQuery(name) LIKE insensitiveQuery('Étranger');`, the engine would run the `insensitiveQuery` function on the string `'Étranger'`, and then look up that result in the index directly, which is O(nlogn) or faster. If you have a million tables, that'd run the function only once (on `Étranger`) and do about 20 lookups in the index before finding you the qualifying row(s).
What you can do is storing the unaccented, simplified version of a word. Which I'm sure pg already does in a way.