Hi, Le samedi 28 juin 2008, Moritz Onken a écrit : > select count(*) > from result > where exists > (select * from item where item.url LIKE result.url || '%' limit 1); > > which basically returns the number of items which exist in table > result and match a URL in table item by its prefix.
It seems you could benefit from the prefix project, which support indexing your case of prefix searches. Your query would then be: SELECT count(*) FROM result r JOIN item i ON r.url @> i.url; The result.url column would have to made of type prefix_range, which casts automatically to text when needed. Find out more about the prefix projects at those urls: http://pgfoundry.org/projects/prefix http://prefix.projects.postgresql.org/README.html Regards, -- dim
signature.asc
Description: This is a digitally signed message part.