Hello I should to search distinct values based on similarity
postgres=# explain select nazobce, nazobce <-> 'Benešov' from obce order by nazobce <-> 'Benešov' limit 10 ; QUERY PLAN ------------------------------------------------------------------------------------------- Limit (cost=0.00..0.86 rows=10 width=10) -> Index Scan using obce_nazobce_idx on obce (cost=0.00..1433.14 rows=16644 width=10) Order By: (nazobce <-> 'Benešov'::text) (3 rows) Time: 0.576 ms but using DISTINCT breaks KNN searching optimization postgres=# explain select distinct nazobce, nazobce <-> 'Benešov' from obce order by nazobce <-> 'Benešov' limit 10 ; QUERY PLAN ----------------------------------------------------------------------------- Limit (cost=600.45..600.47 rows=10 width=10) -> Sort (cost=600.45..613.80 rows=5341 width=10) Sort Key: ((nazobce <-> 'Benešov'::text)) -> HashAggregate (cost=418.27..485.03 rows=5341 width=10) -> Seq Scan on obce (cost=0.00..335.05 rows=16644 width=10) (5 rows) Regards Pavel Stehule -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers