PostgreSQL Overview

COMP9315 21T1 ♢ PostgreSQL Overview ♢ [0/13]
❖ PostgreSQL

PostgreSQL is a full-featured open-source (O)RDBMS.

COMP9315 21T1 ♢ PostgreSQL Overview ♢ [1/13]
❖ PostgreSQL Online

Web site: www.postgresql.org

Key developers: Tom Lane, Andres Freund, Bruce Momjian, ...

Full list of developers: postgresql.org/contributors/

Source code: ~cs9315/21T1/postgresql/src.tar.bz2

Documentation: postgresql.org/docs/12/index.html

COMP9315 21T1 ♢ PostgreSQL Overview ♢ [2/13]
❖ User View of PostgreSQL

Users interact via SQL in a client process, e.g.

$ psql webcms
psql (12.5)
Type "help" for help.
webcms2=# select * from calendar;
 id | course |   evdate   |      event
----+--------+------------+---------------------------
  1 |      4 | 2001-08-09 | Project Proposals due
 10 |      3 | 2001-08-01 | Tute/Lab Enrolments Close
 12 |      3 | 2001-09-07 | Assignment #1 Due (10pm)
 ...

or

$dbconn = pg_connect("dbname=webcms");
$result = pg_query($dbconn,"select * from calendar");
while ($tuple = pg_fetch_array($result))
   { ... $tuple["event"] ... }

COMP9315 21T1 ♢ PostgreSQL Overview ♢ [3/13]
❖ PostgreSQL Functionality

PostgreSQL systems deal with various kinds of entities:

COMP9315 21T1 ♢ PostgreSQL Overview ♢ [4/13]
❖ PostgreSQL Functionality (cont)

PostgreSQL's dialect of SQL is mostly standard (but with extensions).

COMP9315 21T1 ♢ PostgreSQL Overview ♢ [5/13]
❖ PostgreSQL Functionality (cont)

Other variations in PostgreSQL's CREATE TABLE

COMP9315 21T1 ♢ PostgreSQL Overview ♢ [6/13]
❖ PostgreSQL Functionality (cont)

PostgreSQL stored procedures differ from SQL standard:

create function ( Args ) returns ResultType
as $$
... body of function definition ...
$$ language FunctionBodyLanguage;

COMP9315 21T1 ♢ PostgreSQL Overview ♢ [7/13]
❖ PostgreSQL Functionality (cont)

Example:

create or replace function
    barsIn(suburb text) returns setof Bars
as $$
declare
    r record;
begin
    for r in
        select * from Bars where location = suburb
    loop
       return next r;
    end loop;
end;
$$ language plpgsql;
used as e.g.
select * from barsIn('Randwick');

COMP9315 21T1 ♢ PostgreSQL Overview ♢ [8/13]
❖ PostgreSQL Functionality (cont)

Uses multi-version concurrency control (MVCC)

Disadvantages of this approach:
PostgreSQL also provides locking to enforce critical concurrency.
COMP9315 21T1 ♢ PostgreSQL Overview ♢ [9/13]
❖ PostgreSQL Functionality (cont)

PostgreSQL has a well-defined and open extensibility model:

COMP9315 21T1 ♢ PostgreSQL Overview ♢ [10/13]
❖ PostgreSQL Architecture

Client/server process architecture:

[Diagram:Pics/intro/proc-arch.png]


The listener process is sometimes called postmaster

COMP9315 21T1 ♢ PostgreSQL Overview ♢ [11/13]
❖ PostgreSQL Architecture (cont)

Memory/storage architecture:

[Diagram:Pics/intro/mem-arch.png]

COMP9315 21T1 ♢ PostgreSQL Overview ♢ [12/13]
❖ PostgreSQL Architecture (cont)

File-system architecture:

[Diagram:Pics/intro/pg-files.png]

COMP9315 21T1 ♢ PostgreSQL Overview ♢ [13/13]


Produced: 15 Feb 2021