Re: planer picks a bad plan (seq-scan instead of index)

From: "Thomas H(dot)" <me(at)alternize(dot)com>
To: "Richard Huxton" <dev(at)archonet(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: planer picks a bad plan (seq-scan instead of index)
Date: 2006-11-09 12:02:26
Message-ID: 0a2301c703f6$ed06ea40$0201a8c0@iwing
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> Try putting your conditions as part of the join:
> SELECT * FROM shop.dvds
> LEFT JOIN
> oldtables.movies
> ON
> mov_id = dvd_mov_id
> AND (
> lower(mov_name) LIKE '%superman re%'
> OR lower(dvd_name) like '%superman re%'
> OR lower(dvd_edition) LIKE '%superman re%'
> )
> LEFT JOIN shop.data_soundmedia ON sm_info_ean = dvd_ean
>

unfortunately its getting optimized into the same plan :-)

> I'd also be tempted to look at a tsearch2 setup for the word searches.

tsearch2 doesn't work that well for exact matches (including special chars).
but the culprit here isn't the '%...'%' seqscan, but rather the additional
joined table (where no lookup except for the join-column takes place) that
makes the query going from 200ms to 24sec.

regards,
thomas

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sandeep Kumar Jakkaraju 2006-11-09 12:07:41 Too many open cursors
Previous Message Thomas H. 2006-11-09 11:59:33 Re: planer picks a bad plan (seq-scan instead of index) when adding an additional join