keithf4 / pg_bloat_check

Bloat check script for PostgreSQL
Other
139 stars 36 forks source link

GIN indexes not supported. #1

Open coreyatmoat opened 8 years ago

coreyatmoat commented 8 years ago

Got a workaround for this?

$ python pg_bloat_check.py -c dbname=my_db_name
Traceback (most recent call last):
  File "pg_bloat_check.py", line 339, in <module>
    get_bloat(conn, tuple(exclude_schema_list), tuple(include_schema_list), exclude_object_list)
  File "pg_bloat_check.py", line 200, in get_bloat
    cur.execute(sql, [o['oid'], args.min_size, args.min_wasted_size, args.min_wasted_percentage])
  File "/usr/local/lib/python2.7/dist-packages/psycopg2/extras.py", line 120, in execute
    return super(DictCursor, self).execute(query, vars)
psycopg2.NotSupportedError: "my_gin_index_idx" (gin index) is not supported

Unfortunately, I would expect most of the bloat in this db to be in the GIN indexes themselves.

keithf4 commented 8 years ago

Hmm... I'll have to see about exempting them for now. There's another function in pgstattuple that works with gin indexes, but not sure how to interpret its stats as it relates to bloat.

keithf4 commented 8 years ago

Just curious... for the index you believe is bloated, can you run pgstatginindex() on it and share the results? I don't have any clients using GIN indexes at the moment to look into that may have bloat.

coreyatmoat commented 8 years ago
# select pgstatginindex('redacted_index_name');
 pgstatginindex
----------------
 (2,39,940)
(1 row)

I don't particularly think it's bloated (yet), but this database has the potential for bloat, so I was interested in your new query.

keithf4 commented 8 years ago

Ok. I'll see if I can figure anything out. For now just working on a patch to leave GIN indexes out. Thankfully GIST seem to work.

coreyatmoat commented 8 years ago

Happy to help in any way possible.

keithf4 commented 8 years ago

If you come across any queries that are useful for determining GIN bloat, please share. :)

keithf4 commented 8 years ago

Released version 2.0.1 that filters out GIN indexes from scanning so it doesn't error out anymore. Thanks for reporting the issue! Hopefully find something that works eventually.