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@sss.pgh.pa.us> wrote:
>
> Zhihong Zhang <zhihong@gmail.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