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

2023-10-31 Thread Alexander Okulovich
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

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

2023-10-26 Thread Tom Lane
Alexander Okulovich writes: > I've attempted to reproduce this on my PC in Docker from the stage > database dump, but no luck. The first query execution on Postgres 15 > behaves like on the real stage, but subsequent ones use the index. Can you force it in either direction with "set enable_seqs

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

2023-10-26 Thread Alexander Okulovich
Hi Tom, I've attempted to reproduce this on my PC in Docker from the stage database dump, but no luck. The first query execution on Postgres 15 behaves like on the real stage, but subsequent ones use the index. Also, they execute much faster. Looks like the hardware and(or) the data structure

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

2023-10-19 Thread Alexander Okulovich
Hi Tomek, Unfortunately, I didn't dig into this. This request is recommended to provide when describing slow query issues, but looks like it relates to JOINs in the query, which we don't have. Kin

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

2023-10-19 Thread Tomek
Hi Alexander! Apart from the problem you are writing about I'd like to ask you to explain how you interpret counted frac_MCV - for me it has no sense at all to summarize most_common_freqs. Please rethink it and explain what was the idea of such SUM ? I understand that it can be some measure for rat

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

2023-10-18 Thread Tom Lane
Alexander Okulovich writes: > We used the product with the default settings. The requests are simple. > We didn't change the hardware (actually, we use even more performant > hardware because of that issue) and DDL. I've checked the request on old > and new databases. Requests that rely on this

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

2023-10-18 Thread Alexander Okulovich
Hi Tom, If in fact you were getting decent performance from an indexscan plan before, the only explanation I can think of is that the repo_ids you are querying for are correlated with the tenant_id, so that the RLS filter doesn't eliminate very many rows from the index result. The planner would

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

2023-10-18 Thread Alexander Okulovich
Hi Oscar, Thank you for the suggestion. Unfortunately, I didn't mention that on prod we performed the upgrade from Postgres 12 to 15 using replication to another instance with pglogical, so I assume that the index was filled from scratch by Postgres 15. We upgraded stage instance by changin

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

2023-10-13 Thread Tom Lane
Alexander Okulovich writes: > Recently, we upgraded the AWS RDS instance from Postgres 12.14 to 15.4 > and noticed extremely high disk consumption on the following query > execution: > select (exists (select 1 as "one" from "public"."indexed_commit" where > "public"."indexed_commit"."repo_id" i

Postgres 15 SELECT query doesn't use index under RLS

2023-10-13 Thread Alexander Okulovich
Hello everyone! Recently, we upgraded the AWS RDS instance from Postgres 12.14 to 15.4 and noticed extremely high disk consumption on the following query execution: select (exists (select 1 as "one" from "public"."indexed_commit" where "public"."indexed_commit"."repo_id" in (964992,964994,9