"=?iso-8859-9?B?RXJvbCDWeg==?=" <eroloz@esg.com.tr> writes:
> Could anybody give me hint, or reccomend a source about this:
> Please note that two queries are different only in search terms (STAR and
> A). Plan and performane difference between them confused me.
Note the difference in the estimated number of rows matched in
product_t:
> -> Seq Scan on product_t p (cost=0.00..613.41 rows=1 width=94)
> -> Seq Scan on product_t p (cost=0.00..613.41 rows=8321 width=94)
The planner thinks --- not unreasonably, IMHO --- that LIKE '%A%' will
match many more rows than LIKE '%STAR%'. Accordingly, it prepares
different plans for the two cases.
Since you're complaining, I suppose that LIKE '%STAR%' matches many more
rows than random chance would suggest, and so that plan turns out to be
poorly chosen.
regards, tom lane