Re: policies with security definer option for allowing inline optimization

From: Dan Lynch <pyramation(at)gmail(dot)com>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Joe Conway <mail(at)joeconway(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, Isaac Morland <isaac(dot)morland(at)gmail(dot)com>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: policies with security definer option for allowing inline optimization
Date: 2021-04-06 02:51:46
Message-ID: CA+_muLFDzuxZt8DwpzouM=BHe+TOn=YsS+WQ9m7VmxzZ_uYMUw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

This is great, thanks! It's great to have somewhere in the source to read
about the optimizer! very cool!

>
> > I suppose if the
> > get_group_ids_of_current_user() function is marked as STABLE, would the
> > optimizer cache this value for every row in a SELECT that returned
> > multiple rows?
>
> While there was a patch to implement caching, it never finished. The
> optimizer is allowed to, and sometimes does, choose plan shapes that reduce
> the number of function calls.
>

So for multiple rows, it's possible that the same query could happen for
each row? Even if it's clearly stable and only a read operation is
happening?

I suppose if the possibility exists that this could happen, perhaps using
RLS for selects is not quite "production ready"? Or perhaps if the RLS
qual/check is written well-enough, then maybe the performance hit wouldn't
be noticed?

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro Horiguchi 2021-04-06 03:01:19 Re: Asynchronous Append on postgres_fdw nodes.
Previous Message torikoshia 2021-04-06 01:57:01 Re: Get memory contexts of an arbitrary backend process