PostgreSQL Unleashed Marian Marinov Head of System Operations at Siteground.com
What is this talk about Storage Architecture
Authentication
Commands
Writing Functions
Storage Architecture
File system structure Default directory /var/lib/pgsql/data  (PGDATA) / |- postgresql.conf |- pg_hba.conf |- pg_ident.conf |- postmaster.opts |- postmaster.pid |- 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 subsystem |- 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
File system structure Directory representation: 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)
File system structure Directory representation: base -\ |- 11510 -\ | |- 24765 os# SELECT relname,relfilenode,reltablespace FROM  pg_class WHERE relfilenode=24765;  Relname | relfilenode | reltablespace -------------+----------------+--------------- disk_io | 24765 | 0 (1 row)
File system 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.
DataBase Design DBNAME SCHME OBJECTS(table/view/sequence/domain) database -\   |- public   |- scheme1 -\   |   |- table1   |   |- table2   |   |- view1   |   |- view2   |   |- seq1   |   \- seq2   \- scheme2
Authentication
Authentication pg_hba.conf – Host based authentication pg_ident.conf – Identification information Authentication methods: trust – anyone to any DB
reject – do not allow any connections (useful for filtering)
ident -use the system user name or what identd provided
password – use cleartext passwords
md5 – md5 encrypted passwords
pam – use the Password Authentication Mechanism system
Authentication pg_hba.conf: local database  user  auth-method [auth-options] host database  user  CIDR-address auth-method [auth-options] hostssl database  user  CIDR-address auth-method [auth-options] hostnossl database  user  CIDR-address auth-method [auth-options] host database  user  IP-address IP-mask auth-method  [auth-options] hostssl database  user  IP-address IP-mask auth-method  [auth-options] hostnossl database  user  IP-address  IP-mask auth-method  [auth-options]
Authentication pg_ident.conf: map-name system-username database-username example: # MAPNAME SYSTEM-USERNAME PG-USERNAME omicron bryanh bryanh omicron ann ann # bob has user name robert on these machines omicron robert bob # bryanh can also connect as guest1 omicron bryanh guest1
Permissions Every object has its own privileges: Database privileges

Postgre sql unleashed

  • 1.
    PostgreSQL Unleashed MarianMarinov Head of System Operations at Siteground.com
  • 2.
    What is thistalk about Storage Architecture
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
    File system structureDefault directory /var/lib/pgsql/data (PGDATA) / |- postgresql.conf |- pg_hba.conf |- pg_ident.conf |- postmaster.opts |- postmaster.pid |- 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 subsystem |- 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
  • 8.
    File system structureDirectory representation: 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)
  • 9.
    File system structureDirectory representation: base -\ |- 11510 -\ | |- 24765 os# SELECT relname,relfilenode,reltablespace FROM pg_class WHERE relfilenode=24765; Relname | relfilenode | reltablespace -------------+----------------+--------------- disk_io | 24765 | 0 (1 row)
  • 10.
    File system structureTable 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.
  • 11.
    DataBase Design DBNAMESCHME OBJECTS(table/view/sequence/domain) database -\ |- public |- scheme1 -\ | |- table1 | |- table2 | |- view1 | |- view2 | |- seq1 | \- seq2 \- scheme2
  • 12.
  • 13.
    Authentication pg_hba.conf –Host based authentication pg_ident.conf – Identification information Authentication methods: trust – anyone to any DB
  • 14.
    reject – donot allow any connections (useful for filtering)
  • 15.
    ident -use thesystem user name or what identd provided
  • 16.
    password – usecleartext passwords
  • 17.
    md5 – md5encrypted passwords
  • 18.
    pam – usethe Password Authentication Mechanism system
  • 19.
    Authentication pg_hba.conf: localdatabase user auth-method [auth-options] host database user CIDR-address auth-method [auth-options] hostssl database user CIDR-address auth-method [auth-options] hostnossl database user CIDR-address auth-method [auth-options] host database user IP-address IP-mask auth-method [auth-options] hostssl database user IP-address IP-mask auth-method [auth-options] hostnossl database user IP-address IP-mask auth-method [auth-options]
  • 20.
    Authentication pg_ident.conf: map-namesystem-username database-username example: # MAPNAME SYSTEM-USERNAME PG-USERNAME omicron bryanh bryanh omicron ann ann # bob has user name robert on these machines omicron robert bob # bryanh can also connect as guest1 omicron bryanh guest1
  • 21.
    Permissions Every objecthas its own privileges: Database privileges