A
A
axel2018-07-04 11:00:36
PostgreSQL
axel, 2018-07-04 11:00:36

How to improve the performance of TrigramSimilarity?

There is a table with ~300 thousand records, Postgres DB. It is necessary to search the table with typos, for which I use TrigramSimilarity.

SomeModel.objects.annotate(sim=TrigramSimilarity('title', q)).filter(sim__gt=0.05).order_by("-sim")

The title has a GIN index.
The problem is that the search is performed for a very, simply unbearably long time, 15-20 seconds each. The question, in fact, is how to improve performance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question