Re: Index use difference betweer LIKE, LIKE ANY?

Поиск
Список
Период
Сортировка
От Chetan Suttraway
Тема Re: Index use difference betweer LIKE, LIKE ANY?
Дата
Msg-id AANLkTi=bQuynYJY0v9O5V0JdMqMGJELXyAJjBCatW3Dg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Index use difference betweer LIKE, LIKE ANY?  (Josh Berkus <josh@agliodbs.com>)
Ответы Re: Index use difference betweer LIKE, LIKE ANY?  (Robert Haas <robertmhaas@gmail.com>)
Re: Index use difference betweer LIKE, LIKE ANY?  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
Список 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.

Вложения

В списке pgsql-performance по дате отправления:

Предыдущее
От: Samba GUEYE
Дата:
Сообщение: Re: Table partitioning problem
Следующее
От: Shaun Thomas
Дата:
Сообщение: Re: Table partitioning problem