Your SlideShare is downloading. ×
LSA2 - PostgreSQL
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

LSA2 - PostgreSQL

2,119
views

Published on

Published in: Education, Technology

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,119
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
6
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. DataBases - PostgreSQL Linux System Administration II Marian Marinov Linux System Administration II DataBases - PostgreSQL
  • 2. Important links http://www.postgresql.org PostgreSQL 9.3 Documentation PostgreSQL Wiki pgFoundry projects pg-as-nosql-pgday-fosdem-2013.pdf Linux System Administration II DataBases - PostgreSQL
  • 3. Installation Source RPM/DEB Linux System Administration II DataBases - PostgreSQL
  • 4. Directory structure basic /var/lib/pgsql/data/* Debian based /etc/postgresql-common/ /etc/postgresql/9.3/main/ /var/lib/postgresql/9.3/main/ RedHat based old versions /var/lib/pgsql/data/* newer versions /var/lib/pgsql/9.3/data/* Linux System Administration II DataBases - PostgreSQL
  • 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
  • 10. DataBase Design DBNAME SCHME OBJECTS database - (table/view/sequence/domain) |- public |- scheme1 ----- | |- table1 | |- table2 | |- view1 | |- view2 | |- seq1 | - seq2 - scheme2 Linux System Administration II DataBases - PostgreSQL
  • 11. Configuration authentication (pg hba.conf) server (postgresql.conf) storage considerations 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