Re: Index use difference betweer LIKE, LIKE ANY? - Mailing list pgsql-performance

From Chetan Suttraway
Subject Re: Index use difference betweer LIKE, LIKE ANY?
Date
Msg-id AANLkTi=bQuynYJY0v9O5V0JdMqMGJELXyAJjBCatW3Dg@mail.gmail.com
Whole thread Raw
In response to Re: Index use difference betweer LIKE, LIKE ANY?  (Josh Berkus <josh@agliodbs.com>)
Responses Re: Index use difference betweer LIKE, LIKE ANY?
Re: Index use difference betweer LIKE, LIKE ANY?
List pgsql-performance


On Sun, Feb 27, 2011 at 2:43 AM, Josh Berkus <josh@agliodbs.com> wrote:
On 2/25/11 5:31 AM, Sam Wong wrote:
> I found that "LIKE", "= ANY (...)", "LIKE .. OR LIKE .." against a text
> field used the index correctly, but not "LIKE ANY (...)". Would that be a
> bug?

No, it would be a TODO.  This is a known limitation; it needs some
clever code to make it work, and nobody's written it.


came up with attached patch without thinking too much.
With this patch, the explain output for the same query is as below:

postgres=# explain select * from shipment_lookup where (UPPER(lookup) LIKE                  
ANY(ARRAY['SD1102228482%', 'ABCDEFGHIJK%']))
;e
                                           QUERY PLAN                                           
-------------------------------------------------------------------------------------------------
 Seq Scan on shipment_lookup  (cost=0.00..254057.36 rows=2000 width=14)
   Filter: ((upper(lookup) ~~ 'SD1102228482%'::text) OR (upper(lookup) ~~ 'ABCDEFGHIJK%'::text))
(2 rows)

postgres-#

The thing to be noted here is that  the where clause "<pred> LIKE ANY ARRAY[..]"
has been converted into
(<pred> LIKE first_array_element) or (<pred> LIKE second_array_element) or ....

Please pass on your inputs.

Regards,
Chetan

--
Chetan Sutrave
Senior Software Engineer
EnterpriseDB Corporation
The Enterprise PostgreSQL Company
Phone: +91.20.30589523

Website: www.enterprisedb.com
EnterpriseDB Blog: http://blogs.enterprisedb.com/
Follow us on Twitter: http://www.twitter.com/enterprisedb

This e-mail message (and any attachment) is intended for the use of the individual or entity to whom it is addressed. This message contains information from EnterpriseDB Corporation that may be privileged, confidential, or exempt from disclosure under applicable law. If you are not the intended recipient or authorized to receive this for the intended recipient, any use, dissemination, distribution, retention, archiving, or copying of this communication is strictly prohibited. If you have received this e-mail in error, please notify the sender immediately by reply e-mail and delete this message.

Attachment

pgsql-performance by date:

Previous
From: Samba GUEYE
Date:
Subject: Re: Table partitioning problem
Next
From: Shaun Thomas
Date:
Subject: Re: Table partitioning problem