Postgre SQL
Postgre SQL
gnes Kovcs
Budapest, 2015-01-20
Agenda
Introduction
Overview of architecture
Process structure
Shared memory
Concurrency handling
The Optimizer
Introduction
What is PostgreSQL?
open source
object-relational database system
runs on Linux, UNIX (AIX, BSD, HP-UX, SGI IRIX, Mac OS X, Solaris, Tru64), and
Windows
ACID compliant
supported data types: INTEGER, NUMERIC, BOOLEAN, CHAR, VARCHAR, DATE,
INTERVAL, TIMESTAMP and binary large objects
native programming interfaces for C/C++, Java, .Net, Perl, Python, Ruby, Tcl, ODBC
PostgreSQL in numbers
Limit
Value
Unlimited
32 TB
1.6 TB
1 GB
Unlimited
Unlimited
Overview of architecture
pg_logical
pg_multixact
pg_notify
pg_replslot
pg_serial
pg_snapshots
pg_stat
pg_stat_tmp
pg_subtrans
pg_tblspc
pg_twophase
pg_xlog
Description
A file containing the major version number of PostgreSQL
Subdirectory containing per-database subdirectories
Subdirectory containing cluster-wide tables, such as pg_database
Subdirectory containing transaction commit status data
Subdirectory containing files used by the dynamic shared memory
subsystem
Subdirectory containing status data for logical decoding
Subdirectory containing multitransaction status data (used for shared
row locks)
Subdirectory containing LISTEN/NOTIFY status data
Subdirectory containing replication slot data
Subdirectory containing information about committed serializable
transactions
Subdirectory containing exported snapshots
Subdirectory containing permanent files for the statistics subsystem
Subdirectory containing temporary files for the statistics subsystem
Subdirectory containing subtransaction status data
Subdirectory containing symbolic links to tablespaces
Subdirectory containing state files for prepared transactions
Subdirectory containing WAL (Write Ahead Log) files
Data Pages
pages are located under the
database subdirectories
page default size: 8k
additional sizes:4k and 16k but
needs compilation of postgresql
archive_mode: default is false, if true WAL files are archived with the command given
at archive_command
Process structure
Postmaster
main PostgreSQL program
postgres@agideb:~$ pg_ctl status
pg_ctl: server is running (PID: 2971)
/usr/lib/postgresql/9.1/bin/postgres "-D"
"/var/lib/postgresql/9.1/main" "-c"
"config_file=/etc/postgresql/9.1/main/postgresql.conf"
WAL Writer
What is VACUUM?
Shared Memory
to cache pages
Handling concurrency
Dirty Read
Nonrepeatable Read
Phantom Read
Read uncommitted
Possible
Possible
Possible
Read committed
Not possible
Possible
Possible
Repeatable read
Not possible
Not possible
Possible
Serializable
Not possible
Not possible
Not possible
The Optimizer
Join Method
Nested Loop
Hash Join
Merge Join
Join Order
Optimizer statistics
distribution of data:
Sources
http://momjian.us/main/presentations/overview.html
http://www.postgresql.org/
http://raghavt.blogspot.hu/2011/04/postgresql-90-architecture.html