| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> | 
|---|---|
| To: | Zhihong Zhang <zhihong(at)gmail(dot)com> | 
| 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 20:49:18 | 
| Message-ID: | 12042.1577393358@sss.pgh.pa.us | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-bugs | 
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Zhihong Zhang | 2019-12-26 22:25:22 | Re: Indexing on JSONB field not working | 
| Previous Message | Zhihong Zhang | 2019-12-26 19:22:30 | Re: Indexing on JSONB field not working |