From: | Chetan Suttraway <chetan(dot)suttraway(at)enterprisedb(dot)com> |
---|---|
To: | Josh Berkus <josh(at)agliodbs(dot)com> |
Cc: | Sam Wong <sam(at)hellosam(dot)net>, pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Index use difference betweer LIKE, LIKE ANY? |
Date: | 2011-03-15 12:30:00 |
Message-ID: | AANLkTi=bQuynYJY0v9O5V0JdMqMGJELXyAJjBCatW3Dg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Sun, Feb 27, 2011 at 2:43 AM, Josh Berkus <josh(at)agliodbs(dot)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 | Content-Type | Size |
---|---|---|
like_any_array.patch | text/x-diff | 1.3 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Shaun Thomas | 2011-03-15 13:18:45 | Re: Table partitioning problem |
Previous Message | Samba GUEYE | 2011-03-15 10:10:01 | Re: Table partitioning problem |