Re: [9.5] next question: rls and indexes

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: Andreas Kretschmer <akretschmer(at)spamfence(dot)net>
Cc: pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: Re: [9.5] next question: rls and indexes
Date: 2015-07-22 21:04:02
Message-ID: CAEZATCWm6fVtLWcAF6po+C0=aQLOmoK=wEy6S45aSPUZvzD3Wg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 15 July 2015 at 09:34, Andreas Kretschmer <akretschmer(at)spamfence(dot)net> wrote:
> test=> explain select * from rls_test ;
> QUERY PLAN
> -------------------------------------------------------------
> Seq Scan on rls_test (cost=0.00..630.00 rows=91 width=335)
> Filter: (name = ("current_user"())::text)
> (2 rows)
>
> As you can see, the index isn't in use, but i think, in this case PG
> should use it.
>
> Bug or Feature?
>

Yes, that's a bug. It should indeed use the index for queries like
that. Debugging it reveals that the reason it didn't is a collation
mismatch which caused it to believe there were no suitable indexes to
use.

Fortunately this has been fixed (post 9.5 alpha 1) -- see
http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=808ea8fc7bb259ddd810353719cac66e85a608c8
-- and the same query on HEAD now does use the index.

Thanks for testing.

Regards,
Dean

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tim Smith 2015-07-23 07:06:19 Re: Delete rule does not prevent truncate
Previous Message Миша Тюрин 2015-07-22 16:34:56 Re: [GENERAL] Way to get timeline