From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Kevin Grittner <kgrittn(at)mail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: ToDo: KNN Search should to support DISTINCT clasuse? |
Date: | 2012-10-26 06:56:00 |
Message-ID: | CAFj8pRDJ7SO2DQ1zbghT5OpyDxSnA6b74iZMczfwApN_cFSbFQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
2012/10/25 Kevin Grittner <kgrittn(at)mail(dot)com>:
> Tom Lane wrote:
>> "Kevin Grittner" <kgrittn(at)mail(dot)com> writes:
>> > Pavel Stehule wrote:
>> >> 2012/10/22 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>> >>> Perhaps it would be close enough to what you want to use DISTINCT ON:
>> >>> contrib_regression=# explain select distinct on( t <-> 'foo') *,t <-> 'foo' from test_trgm order by t <-> 'foo' limit 10;
>>
>> >> good tip - it's working
>>
>> > If two or more values happen to be at exactly the same distance,
>> > wouldn't you just get one of them?
>>
>> Yeah, that is a hazard. I'm not sure whether <->'s results are
>> sufficiently quantized to make that a big problem in practice.
>
> It doesn't seem too far-fetched for trigram queries:
>
> test=# select nm, nm <-> 'anders' from (values ('anderson'),('andersen'),('andersly')) x(nm);
> nm | ?column?
> ----------+----------
> anderson | 0.4
> andersen | 0.4
> andersly | 0.4
> (3 rows)
>
> test=# select distinct on (nm <-> 'anders') nm, nm <-> 'anders' from (values ('anderson'),('andersen'),('andersly')) x(nm) order by nm <-> 'anders' limit 3;
> nm | ?column?
> ----------+----------
> anderson | 0.4
> (1 row)
yes it is issue - but I am thinking about simple "fuzzy" searching, so
exact result is not strongly expected. On second hand if SELECT
DISTINCT * will be supported it should be nice.
Pavel
>
> -Kevin
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Kapila | 2012-10-26 07:04:47 | Re: autovacuum truncate exclusive lock round two |
Previous Message | Rushabh Lathia | 2012-10-26 06:28:21 | Query ending up with hitting all the partition with sub-query in the projection list |