when i go into sql-8.2/base/
to check how much space does my table take, there are plenty of files named by a number. how can i find the specific file which sto
Each directory represents a database (created via create database
). The number is the oid of the database. To see the oid and its name, run the following statement:
select oid, datname
from pg_database;
Inside each directory each file corresponds to the an entry in pg_class
where the oid matches the number of the file in the directory:
You can see the oids and to which relation they relate by running the statement:
select cl.relfilenode, nsp.nspname as schema_name, cl.relname, cl.relkind
from pg_class cl
join pg_namespace nsp on cl.relnamespace = nsp.oid;
You might also want to check out the manual
Btw: if you are really still running 8.2 you should upgrade as soon as possible.
select pg_relation_filepath('OID or name of a table, index, sequence, or toast table');
For example:
select pg_relation_filepath('flush_history');
Returns base/83780/153211 which you will find in your data directory.
http://www.postgresql.org/docs/current/static/functions-admin.html
To check how much space the table takes use:
SELECT pg_size_pretty(pg_total_relation_size('table_name_here'))
It will give you the size of a table with its indexes and "toast" tables. Details here.