5. Structure of PostgreSQL
server
prefork (shared memory)
client handling (client library)
query parser
query analyzer
query planner
plug-in modules
storage engine
maintenance processes
client
client library
parser
autocomplete
Linux System Administration II DataBases - PostgreSQL
6. On disk data structure
|
|- PG_VERSION
|- base per-database subdirectories
|- global cluster-wide tables, such as pg_database
|- pg_clog transaction commit status data
|- pg_multixact multitransaction status data
|- pg_stat_tmp temporary files for the statistics subsyste
|- pg_subtrans subtransaction status data
|- pg_tblspc symbolic links to tablespaces
|- pg_twophase state files for prepared transactions
|- pg_xlog WAL (Write Ahead Log) files
|...
Linux System Administration II DataBases - PostgreSQL
7. On disk data structure
base -
|- 1
|- 11510
|- 11511
|- 16384
- 24576
template1=# SELECT datname,datlastsysoid FROM pg_database;
datname | datlastsysoid
-------------+----------------
template1 | 11510
template0 | 11510
postgres | 11510
os | 11510
(5 rows)
Linux System Administration II DataBases - PostgreSQL
8. On disk data structure
base -
|- 11510 -
| |- 24765
os# SELECT relname,relfilenode,reltablespace FROM pg_class
WHERE relfilenode=24765;
Relname | relfilenode | reltablespace
------------+---------------+---------------
disk_io | 24765 | 0
(1 row)
Linux System Administration II DataBases - PostgreSQL
9. On disk data structure
Table and Indexes are stored in separate files
Tables bigger then 1GB are split into different files:
filenode.1, filenode.2, . . . , filenode.N
The 1GB limit can be changed during build using
–with-segsize configure option.
Linux System Administration II DataBases - PostgreSQL
12. Working with PgSQL (psql and phpPgAdmin)
start/stop/restart/reload the server
server resouce limits(ulimits)
kernel tunning for PgSQL
Linux System Administration II DataBases - PostgreSQL
13. Working with PgSQL (psql and phpPgAdmin)
storage types
standard types
XML/JSON
Network datatypes
PostGIS
ARRAYs
User defined types (UDT)
tablespaces
list databases
list users
grant/revoke privileges
creating/destroying users
creating/destroying databases
creating/destroying schemas
creating/destroying tables
Linux System Administration II DataBases - PostgreSQL
14. Working with PgSQL (psql and phpPgAdmin)
creating/destroying constrains
creating/destroying indexes
creating/destroying sequences
VACUUM/AUTOVACUUM
VACUUM vs. ANALYZE
built-in functions
writing user functions
adding a language to a database
supported languages (SQL, pl/pgSQL, PL/Python, PL/Perl,
PL/TCL, pl/V8, PL/R, PL/LUA, C)
adding an extension to a database
Foreign data wrappers
Linux System Administration II DataBases - PostgreSQL
15. Backup and restores
pg dump
pg dumpall
LVM snapshots
Via replication
WAL
Linux System Administration II DataBases - PostgreSQL
16. Monitoring
EXPLAIN ( Planner Cost Constants )
ps axf. . .
monitoring server
monitoring tables & indexes
Linux System Administration II DataBases - PostgreSQL