ToDo: KNN Search should to support DISTINCT clasuse?

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: ToDo: KNN Search should to support DISTINCT clasuse?
Date: 2012-10-22 13:10:22
Message-ID: CAFj8pRAzY4duEw-NzMyst3arBLX0YEyHYmS1ET+K0yu0SWHO_A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2012-10-22 13:33:58 Re: [v9.3] Row-Level Security
Previous Message Tom Lane 2012-10-22 12:57:31 Re: Deprecating RULES