Sunday, November 6, 2011

Postgresql - The pg_class table

Another very useful catalog table.

http://www.postgresql.org/docs/9.0/interactive/catalog-pg-class.html
The catalog pg_class catalogs tables and most everything else that has columns or is otherwise similar to a table. This includes indexes (but see also pg_index), sequences, views, composite types, and TOAST tables; see relkind. Below, when we mean all of these kinds of objects we speak of "relations". Not all columns are meaningful for all relation types.

For instance in another post I have described the following error:

ERROR: could not read block 18875 of relation base/105574/105673: read only 0 of 8192 bytesERROR:

[sourcecode language="sql"]

dw_ifrembi=> select * from pg_class where relfilenode = 105673;
-[ RECORD 1 ]--+---------------------------------------------------
relname        | fact_servicio_referencia_pago
relnamespace   | 2200
reltype        | 105675
relowner       | 10
relam          | 0
relfilenode    | 105673
reltablespace  | 0
relpages       | 15766
reltuples      | 1.15017e+06
reltoastrelid  | 0
reltoastidxid  | 0
relhasindex    | t
relisshared    | f
relistemp      | f
relkind        | r
relnatts       | 11
relchecks      | 0
relhasoids     | f
relhaspkey     | t
relhasrules    | f
relhastriggers | t
relhassubclass | f
relfrozenxid   | 11192264
relacl         | {postgres=arwdDxt/postgres,ifrem=arwdDxt/postgres}
reloptions     |

[/sourcecode]

In this case the number 105673 being the relfilenode, gave me the name of the relation where this issue was arising.

No comments:

Post a Comment