индексы:
idx(id)
idx(order_id, created_at desc)
Запрос:
select distinct first_value(w.id) over (
partition by w.order_id
order by w.created_at desc
)
from webhook.webhook_inbox as w
where extract(epoch from (now() - w.updated_at)) >= 50 and status_id = 3
limit 100;
https://t.me/pgsql/303899
Обсуждают сегодня