> SELECT distinct url from item where url like 'http://www.micro%' limit
> 10;
Here, the planner knows the pattern beforehand, and can see that it's a
simple prefix.
> select *
> from result
> where exists
> (select * from item where item.url LIKE result.url || '%' limit 1)
> limit 10;
Here it cannot (what if result.url was '%foo%'?).
Try using something like (item.url >= result.url && item.url <= result.url ||
'z'), substituting an appropriately high character for 'z'.
> The only explaination is that I don't use a constant when comparing the
> values. But actually it is a constant...
It's not a constant at planning time.
Also note that you'd usually want to use IN instead of a WHERE EXISTS.
/* Steinar */
--
Homepage: http://www.sesse.net/
--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance
No comments:
Post a Comment