Re: [HACKERS] workaround for expensive KNN?

2011-04-11 Thread PostgreSQL - Hans-Jürgen Schönig
price has a problem :(. iphone can be a 20 cents bag or a sticker or a 900 euro thing signed by whoever ... so, words and the sort-number / price are not related in anyway. price is in this case no way to narrow down the problem (e.g. evaluate first or so). many thanks,

[HACKERS] workaround for expensive KNN?

2011-04-08 Thread PostgreSQL - Hans-Jürgen Schönig
hello all ... given oleg's posting before i also wanted to fire up some KNN related question. let us consider a simple example. i got some million lines and i want all rows matching a tsquery sorted by price. i did some tests: test=# explain (analyze true, buffers true, costs true) SELECT id

Re: [HACKERS] workaround for expensive KNN?

2011-04-08 Thread Oleg Bartunov
Probably, you miss two-columnt index. From my early post: http://www.sai.msu.su/~megera/wiki/knngist =# CREATE INDEX spots_idx ON spots USING knngist (coordinates, to_tsvector('french',address)); =# SELECT id, address, (coordinates - '(2.29470491409302,48.858263472125)'::point) AS dist FROM

Re: [HACKERS] workaround for expensive KNN?

2011-04-08 Thread Oleg Bartunov
Hans, what if you create index (price,title) ? On Fri, 8 Apr 2011, PostgreSQL - Hans-J?rgen Sch?nig wrote: hello ... i got that one ... idx_product_t_product_titleprice gist (to_tsvector('german'::regconfig, title), int_price) so, i have a combined index on text + number. to me the

Re: [HACKERS] workaround for expensive KNN?

2011-04-08 Thread Tom Lane
Oleg Bartunov o...@sai.msu.su writes: what if you create index (price,title) ? I think that SELECT ... WHERE ... ORDER BY ... LIMIT is basically an intractable problem. We've recognized the difficulty in connection with btree indexes for a long time, and there is no reason at all to think that

Re: [HACKERS] workaround for expensive KNN?

2011-04-08 Thread PostgreSQL - Hans-Jürgen Schönig
hello ... i got that one ... idx_product_t_product_titleprice gist (to_tsvector('german'::regconfig, title), int_price) so, i have a combined index on text + number. to me the plan seems fine ... it looks like a prober KNN traversal. the difference between my plan and your plan seems to be

Re: [HACKERS] workaround for expensive KNN?

2011-04-08 Thread Oleg Bartunov
Oops, my previous example was fromm early prototype :) I just recreated test environment for 9.1: knn=# select count(*) from spots; count 908846 (1 row) knn=# explain (analyze true, buffers true) SELECT id, address, (coordinates - '(2.29470491409302,48.858263472125)'::point) AS