Re: Indexing on JSONB field not working

From: Zhihong Zhang <zhihong(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Indexing on JSONB field not working
Date: 2019-12-26 22:25:22
Message-ID: F075C03D-B73B-4A59-B080-101331F8814C@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I am not superuser. Let me see how I can get access to the superuser on RDS.

I will get back to you.

Thanks!

Zhihong

> On Dec 26, 2019, at 3:49 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Zhihong Zhang <zhihong(at)gmail(dot)com> writes:
>> I looked at pg_stats for all our databases. None of them have stats on indexes. Are there any settings disabling this?
>
> No, I don't think so. We only collect stats on index expressions, though,
> not simple columns (since those would be duplicative of the underlying
> column's stats).
>
> Hmmm ... looking at the pg_stats view, it has a filter
>
> WHERE NOT a.attisdropped AND
> has_column_privilege(c.oid, a.attnum, 'select'::text) AND
> (c.relrowsecurity = false OR NOT row_security_active(c.oid))
>
> The has_column_privilege test might be getting in the way if you're
> not superuser; it will probably think you have no access privileges
> for the index. I now recall somebody complaining about that before [1],
> but no fix has been accepted as yet.
>
> Having said that, though, that only accounts for you not seeing the
> entries in the pg_stats view; it doesn't explain why the optimizer
> doesn't see them, assuming they're actually there in pg_statistic,
> which they surely should be.
>
> As I recall, RDS doesn't give out superuser access, so it may be
> hard for you to learn more about what's happening :-(
>
> regards, tom lane
>
> [1] https://www.postgresql.org/message-id/flat/6369212.CF36pTLAQO%40peanuts2

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tomas Vondra 2019-12-26 23:41:24 Re: Indexing on JSONB field not working
Previous Message Tom Lane 2019-12-26 20:49:18 Re: Indexing on JSONB field not working