Re: Slow search.. quite clueless

From: Yonatan Ben-Nes <da(at)canaan(dot)co(dot)il>
To: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>
Cc: armtuk(at)gmail(dot)com, postgresql(at)philip(dot)pjkh(dot)com, olly(at)survex(dot)com, qnex42(at)gmail(dot)com, gabor(at)nekomancer(dot)net, pgsql-general(at)postgresql(dot)org
Subject: Re: Slow search.. quite clueless
Date: 2005-09-26 19:38:46
Message-ID: 43384E46.1080901@canaan.co.il
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Oleg Bartunov wrote:
> On Mon, 26 Sep 2005, Yonatan Ben-Nes wrote:
>
>> Hi again everyone,
>>
>> Oleg I tried tsearch2 and happily it does work wonderfully for me
>> returning results extremly fast and actually its working even better
>> then I wanted with all of those neat features like: lexem, weight &
>> stop words.
>>
>> I got only one problem which is when I want the results to be ordered
>> by a diffrent field (like print INT field) it takes quite alot of time
>> for it to do it if the query can return lots of results (for example
>> search for the word "computer") and thats even if I limit the results.
>> The best way to improve its speed for such quereies (that I've
>> found...) is to create an index on the field which I want to order by
>> and using it CLUSTER the table, after the clustering I drop the the
>> index so it won't be used when I run queries with ORDER BY on that
>> field, that seem to improve the speed, if anyone got a better idea ill
>> be glad to hear it.
>
>
> what's your actual query ? have you tried multicolumn index ?
>
>
>>
>> Anyway thanks alot everyone!
>> Ben-Nes Yonatan
>>
>
> Regards,
> Oleg
> _____________________________________________________________
> Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
> Sternberg Astronomical Institute, Moscow University (Russia)
> Internet: oleg(at)sai(dot)msu(dot)su, http://www.sai.msu.su/~megera/
> phone: +007(095)939-16-83, +007(095)939-23-83

Hi Oleg,

I can't use a multicolumn index cause I already use on that table the
tsearch2 index, here is the query:

EXPLAIN ANALYZE SELECT product_id,final_price FROM product WHERE
keywords_vector @@ to_tsquery('cat') ORDER BY retail_price LIMIT 13;

QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=4.02..4.03 rows=1 width=39) (actual time=367.627..367.654
rows=13 loops=1)
-> Sort (cost=4.02..4.03 rows=1 width=39) (actual
time=367.622..367.630 rows=13 loops=1)
Sort Key: retail_price
-> Index Scan using product_keywords_vector_idx on product
(cost=0.00..4.01 rows=1 width=39) (actual time=0.056..276.385 rows=14295
loops=1)
Index Cond: (keywords_vector @@ '\'cat\''::tsquery)
Total runtime: 370.916 ms
(6 rows)

Now this is the result after its already at the cache (made such a query
b4), the first time I ran this query it took few seconds...

Thanks as always :),
Ben-Nes Yonatan

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2005-09-26 19:42:40 Re: insertion becoming slow
Previous Message Raj Gupta 2005-09-26 19:37:19 Re: Error migrating from 7.4.3 to 8.0.3