Re: Query performance issue

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: Query performance issue
Дата
Msg-id CAApHDvpUU3S4EOWE4vCDHSp+S4yxoH0hxH96GojPH7J9+ZhiAw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Query performance issue  (Nagaraj Raj <nagaraj.sf@yahoo.com>)
Список pgsql-performance
On Sat, 5 Sep 2020 at 10:20, Nagaraj Raj <nagaraj.sf@yahoo.com> wrote:
> I added the index as you suggested and the planner going through the bitmap index scan,heap and the new planner is,
> HaOx | explain.depesz.com

In addition to that index, you could consider moving away from
standard SQL and use DISTINCT ON, which is specific to PostgreSQL and
should give you the same result.

EXPLAIN ANALYZE
SELECT DISTINCT ON (serial_no) serial_no,receivingplant,sku,r3_eventtime
FROM receiving_item_delivered_received
WHERE eventtype='LineItemdetailsReceived'
  AND replenishmenttype = 'DC2SWARRANTY'
  AND coalesce(serial_no,'') <> ''
ORDER BY serial_no,eventtime DESC;

The more duplicate serial_nos you have the better this one should
perform.  It appears you don't have too many so I don't think this
will be significantly faster, but it should be a bit quicker.

David



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

Предыдущее
От: Nagaraj Raj
Дата:
Сообщение: Re: Query performance issue
Следующее
От: Michael Lewis
Дата:
Сообщение: Re: Query performance issue