Re: Postgres 15 SELECT query doesn't use index under RLS

Поиск
Список
Период
Сортировка
От Alexander Okulovich
Тема Re: Postgres 15 SELECT query doesn't use index under RLS
Дата
Msg-id 6c888a16-b206-4817-b5ca-9e09b904edde@stiltsoft.com
обсуждение исходный текст
Ответ на Re: Postgres 15 SELECT query doesn't use index under RLS  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Postgres Locking  ("Dirschel, Steve" <steve.dirschel@thomsonreuters.com>)
Список pgsql-performance

Hi Tom,

Can you force it in either direction with "set enable_seqscan = off"
(resp. "set enable_indexscan = off")?  If so, how do the estimated
costs compare for the two plan shapes?
Here are the results from the prod instance:

seqscan off

indexscan_off

Just noticed that the WHEN clause differs from the initial one (392 ids under RLS). Probably, this is why the execution time isn't so catastrophic. Please let me know if this matters, and I'll rerun this with the initial request. Speaking of the stage vs local Docker Postgres instance, the execution time on stage is so short (0.1 ms with seq scan, 0.195 with index scan) that we probably should not consider them. But I'll execute the requests if it's necessary.

Maybe your prod installation has a bloated index, and that's driving
up the estimated cost enough to steer the planner away from it.
We tried to make REINDEX CONCURRENTLY on a prod copy, but the planner still used Seq Scan instead of Index Scan afterward.

Kind regards,

Alexander

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Postgres 15 SELECT query doesn't use index under RLS
Следующее
От: "Dirschel, Steve"
Дата:
Сообщение: Postgres Locking