Re: LIKE CLAUSE on VIEWS

Поиск
Список
Период
Сортировка
От Jeff Janes
Тема Re: LIKE CLAUSE on VIEWS
Дата
Msg-id CAMkU=1waKK_oe1omYO9xHOed0M-B3oQMcG4n9znEp0HOxy8aqA@mail.gmail.com
обсуждение исходный текст
Ответ на LIKE CLAUSE on VIEWS  (aditya desai <admad123@gmail.com>)
Список pgsql-performance
On Sun, Jan 22, 2023 at 6:34 AM aditya desai <admad123@gmail.com> wrote:
Hi,
Is there any way to improve performance of LIKE clause on VIEWS.

select * From request_vw where upper(status) like '%CAPTURED%' - 28 seconds.

You would need to have an expression index over upper(status) to support such a query, not an index on status itself.  It would probably be better to just use ILIKE rather than upper(), so `status ILIKE '%captured%'`, which can benefit from an index on "status" itself.

Also as this is VIEW TRIGRAM nor normal indexes don't get used.

There is no problem in general using trigram indexes (or any other index types) on views.  Maybe your view has particular features which inhibit the use of the index, but you haven't given any information which would be useful for assessing that.  Did you try an index, or just assume it wouldn't work without trying?
 
Cheers,

Jeff

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

Предыдущее
От: Rick Otten
Дата:
Сообщение: Re: LIKE CLAUSE on VIEWS
Следующее
От: Mok
Дата:
Сообщение: Database Stalls