Introbook v4 en
Introbook v4 en
We have written this small book for those who only start
getting acquainted with the world of PostgreSQL. From
this book, you will learn:
Good luck!
1
About PostgreSQL
PostgreSQL is the most feature-rich free open-source
DBMS. Developed in the academic environment, this DBMS
has brought together a wide developer community through
its long history and now offers all the functionality re-
quired by most customers. PostgreSQL is actively used all
over the world to create high-load business-critical sys-
tems.
Some History
2
Draft as of 29-Dec-2017
3
Draft as of 29-Dec-2017
Development
The Core team of the project takes all the main decisions
about developing and releasing new versions. At the mo-
ment, it consists of five people.
4
Draft as of 29-Dec-2017
5
Draft as of 29-Dec-2017
Support
Current State
6
Draft as of 29-Dec-2017
Security
7
Draft as of 29-Dec-2017
Transaction Support
8
Draft as of 29-Dec-2017
9
Draft as of 29-Dec-2017
Query Planner
Indexing
10
Draft as of 29-Dec-2017
11
Draft as of 29-Dec-2017
Cross-Platform Support
Extensibility
• data types
12
Draft as of 29-Dec-2017
• loadable extensions
Availability
13
Draft as of 29-Dec-2017
Independence
14
Installation and Quick Start
What is required to get started with PostgreSQL? In this
chapter, we’ll explain how to install and manage Post-
greSQL service, and then show how to set up a simple
database and create tables in it. We will explain the ba-
sics of the SQL language, which is used for data queries.
It’s a good idea to start trying SQL commands while you
are reading this chapter.
15
Draft as of 29-Dec-2017
Windows
Installation
16
Draft as of 29-Dec-2017
Choose components:
17
Draft as of 29-Dec-2017
Installation folder:
18
Draft as of 29-Dec-2017
You can also specify a directory that will store the databases.
This directory will hold all the information stored in DBMS,
so make sure you have enough disk space if you are plan-
ning to store a lot of data.
19
Draft as of 29-Dec-2017
Server options:
You can leave the default settings in all the other fields.
20
Draft as of 29-Dec-2017
21
Draft as of 29-Dec-2017
To start the service, you can run the “Start Server” pro-
gram from the same folder.
22
Draft as of 29-Dec-2017
Installation
23
Draft as of 29-Dec-2017
$ locale
$ export LC_CTYPE=ru_RU.UTF8
$ export LC_COLLATE=ru_RU.UTF8
You should also make sure that the operating system has
the required locale installed:
24
Draft as of 29-Dec-2017
ru_RU.utf8
25
Draft as of 29-Dec-2017
26
Draft as of 29-Dec-2017
• /var/lib/pgpro/std-10/data/postgresql.conf —
the main configuration file that contains server pa-
rameters.
• /var/lib/pgpro/std-10/data/pg_hba.conf — the
file defining access settings. For security reasons,
the access is only allowed from the local system on
behalf of the postgres OS user by default.
Now it’s time to connect to the database and try out SQL.
27
Trying SQL
Connecting via psql
28
Draft as of 29-Dec-2017
29
Draft as of 29-Dec-2017
Database
postgres=# \c test
You are now connected to database "test" as user
"postgres".
30
Draft as of 29-Dec-2017
test=#
The command that we’ve just entered does not look like
SQL — it starts with a backslash. This is a convention for
special commands that can only be used in psql (so if
you are using pgAdmin or another GUI tool, skip all com-
mands starting with the backslash, or try to find an equiv-
alent).
test=# \?
Tables
31
Draft as of 29-Dec-2017
32
Draft as of 29-Dec-2017
You can find the exact syntax of the CREATE TABLE com-
mand in documentation, or view command-line help right
in psql:
33
Draft as of 29-Dec-2017
34
Draft as of 29-Dec-2017
Data Retrieval
Simple Queries
To read data from tables, use the SELECT operator. For ex-
ample, let’s display two columns from the courses table:
35
Draft as of 29-Dec-2017
The result can contain several rows with the same data.
Even if all rows in the original table are different, the
data can appear duplicated if not all the columns are dis-
played:
36
Draft as of 29-Dec-2017
37
Draft as of 29-Dec-2017
Remember:
Joins
38
Draft as of 29-Dec-2017
39
Draft as of 29-Dec-2017
Networks | 1451 | 5
Networks | 1432 | 4
(4 rows)
This example shows that the result does not include the
rows of the original table that do not have a pair in the
other table: although the condition is applied to the sub-
jects, the students that did not take an exam in this sub-
ject are also excluded. To include all students into the
result, regardless of whether they took this exam, use the
outer join:
40
Draft as of 29-Dec-2017
name | score
--------+-------
Anna | 5
Victor | 4
Nina |
(3 rows)
In this example, rows from the left table that don’t have
a counterpart in the right table are added to the result
(that’s why the operation is called LEFT JOIN). The corre-
sponding values in the right table are undefined in this
case.
41
Draft as of 29-Dec-2017
Subqueries
test=# SELECT *
FROM exams
WHERE (SELECT start_year
42
Draft as of 29-Dec-2017
FROM students
WHERE students.s_id = exams.s_id) > 2014;
s_id | c_no | score
------+-------+-------
1556 | CS301 | 5
(1 row)
Let’s display all students who have any scores in the spec-
ified course:
43
Draft as of 29-Dec-2017
name | start_year
------+------------
Anna | 2014
Nina | 2015
(2 rows)
44
Draft as of 29-Dec-2017
Sorting
45
Draft as of 29-Dec-2017
Grouping Operations
46
Draft as of 29-Dec-2017
47
Draft as of 29-Dec-2017
48
Draft as of 29-Dec-2017
Transactions
49
Draft as of 29-Dec-2017
test=# \d students
Table "public.students"
Column | Type | Modifiers
------------+---------+----------
s_id | integer | not null
name | text |
start_year | integer |
g_no | text |
...
You can get the list of all tables available in the data-
base:
test=# \d
List of relations
Schema | Name | Type | Owner
--------+----------+-------+----------
public | courses | table | postgres
public | exams | table | postgres
public | groups | table | postgres
public | students | table | postgres
(4 rows)
50
Draft as of 29-Dec-2017
test=# BEGIN;
BEGIN
postgres=# \c test
You are now connected to database "test" as user
"postgres".
test=# SELECT * FROM groups;
51
Draft as of 29-Dec-2017
g_no | monitor
------+---------
(0 rows)
test=# COMMIT;
COMMIT
52
Draft as of 29-Dec-2017
g_no | monitor
-------+---------
A-101 | 1451
(1 row)
test=# SELECT * FROM students;
s_id | name | start_year | g_no
------+--------+------------+-------
1451 | Anna | 2014 | A-101
1432 | Victor | 2014 | A-101
1556 | Nina | 2015 | A-101
(3 rows)
53
Draft as of 29-Dec-2017
54
Draft as of 29-Dec-2017
\l List of databases.
55
Draft as of 29-Dec-2017
Conclusion
test=# \q
56
Demo Database
Description
General Information
57
58
Bookings Airports
# book_ref # airport_code
* book_date * airport_name
* total_amount * city
* coordinates
* timezone
Draft as of 29-Dec-2017
59
Draft as of 29-Dec-2017
Bookings
Tickets
Note that neither the passenger ID, nor the name is per-
manent (for example, one can change the last name or
60
Draft as of 29-Dec-2017
Flight Segments
Each flight has its cost (amount) and travel class (fare_con-
ditions).
Flights
61
Draft as of 29-Dec-2017
62
Draft as of 29-Dec-2017
• Scheduled
The flight is available for booking. It happens one
month before the planned departure date; before
that time, there is no entry for this flight in the
database.
• On Time
The flight is open for check-in (twenty-four hours
before the scheduled departure) and is not delayed.
• Delayed
The flight is open for check-in (twenty-four hours
before the scheduled departure) but is delayed.
• Departed
The aircraft has already departed and is airborne.
• Arrived
The aircraft has reached the point of destination.
• Cancelled
The flight is cancelled.
63
Draft as of 29-Dec-2017
Airports
Boarding Passes
Aircraft
64
Draft as of 29-Dec-2017
Seats
Flights View
• flight duration
scheduled_duration, actual_duration.
65
Draft as of 29-Dec-2017
Routes View
66
Draft as of 29-Dec-2017
Installation
• edu.postgrespro.com/demo-small.zip — a small
database with flight data for one month (21 MB, DB
size is 280 MB).
• edu.postgrespro.com/demo-medium.zip — a medium
database with flight data for three months (62 MB,
DB size is 702 MB).
• edu.postgrespro.com/demo-big.zip — a large
database with flight data for one year (232 MB, DB
size is 2638 MB).
67
Draft as of 29-Dec-2017
$ sudo su - postgres
$ wget https://edu.postgrespro.com/demo-small.zip
postgres# \i demo-small-20170815.sql
(If the file is not found, check the “Start in” property of
the shortcut; the file must be located in this directory).
Sample Queries
postgres=# \c demo
You are now connected to database "demo" as user
"postgres".
68
Draft as of 29-Dec-2017
demo=#
69
Draft as of 29-Dec-2017
70
Draft as of 29-Dec-2017
Simple Queries
71
Draft as of 29-Dec-2017
SELECT t.passenger_name,
b.book_date
FROM bookings b
JOIN tickets t
ON t.book_ref = b.book_ref
JOIN boarding_passes bp
ON bp.ticket_no = t.ticket_no
JOIN flights f
ON f.flight_id = bp.flight_id
WHERE f.departure_airport = 'SVO'
AND f.arrival_airport = 'OVB'
AND f.scheduled_departure::date =
bookings.now()::date - INTERVAL '2 day'
AND bp.seat_no = '1A';
SELECT count(*)
FROM flights f
JOIN seats s
ON s.aircraft_code = f.aircraft_code
WHERE f.flight_no = 'PG0404'
AND f.scheduled_departure::date =
bookings.now()::date - INTERVAL '1 day'
AND NOT EXISTS (
SELECT NULL
FROM boarding_passes bp
WHERE bp.flight_id = f.flight_id
AND bp.seat_no = s.seat_no
);
72
Draft as of 29-Dec-2017
SELECT count(*)
FROM (
SELECT s.seat_no
FROM seats s
WHERE s.aircraft_code = (
SELECT aircraft_code
FROM flights
WHERE flight_no = 'PG0404'
AND scheduled_departure::date =
bookings.now()::date - INTERVAL '1 day'
)
EXCEPT
SELECT bp.seat_no
FROM boarding_passes bp
WHERE bp.flight_id = (
SELECT flight_id
FROM flights
WHERE flight_no = 'PG0404'
AND scheduled_departure::date =
bookings.now()::date - INTERVAL '1 day'
)
) t;
73
Draft as of 29-Dec-2017
SELECT f.flight_no,
f.scheduled_departure,
f.actual_departure,
f.actual_departure - f.scheduled_departure
AS delay
FROM flights f
WHERE f.actual_departure IS NOT NULL
ORDER BY f.actual_departure - f.scheduled_departure
DESC
LIMIT 10;
Aggregate Functions
74
Draft as of 29-Dec-2017
SELECT f.flight_no,
f.scheduled_duration,
min(f.actual_duration),
max(f.actual_duration),
sum(CASE
WHEN f.actual_departure >
f.scheduled_departure +
INTERVAL '1 hour'
THEN 1 ELSE 0
END) delays
FROM flights_v f
WHERE f.departure_city = 'Москва'
AND f.arrival_city = 'Санкт-Петербург'
AND f.status = 'Arrived'
GROUP BY f.flight_no,
f.scheduled_duration;
SELECT t.passenger_name,
t.ticket_no
FROM tickets t
JOIN boarding_passes bp
ON bp.ticket_no = t.ticket_no
GROUP BY t.passenger_name,
t.ticket_no
HAVING max(bp.boarding_no) = 1
AND count(*) > 1;
75
Draft as of 29-Dec-2017
SELECT tt.cnt,
count(*)
FROM (
SELECT t.book_ref,
count(*) cnt
FROM tickets t
GROUP BY t.book_ref
) tt
GROUP BY tt.cnt
ORDER BY tt.cnt;
Window Functions
76
Draft as of 29-Dec-2017
SELECT tf.ticket_no,
f.departure_airport,
f.arrival_airport,
f.scheduled_arrival,
lead(f.scheduled_departure) OVER w
AS next_departure,
lead(f.scheduled_departure) OVER w -
f.scheduled_arrival AS gap
FROM bookings b
JOIN tickets t
ON t.book_ref = b.book_ref
JOIN ticket_flights tf
ON tf.ticket_no = t.ticket_no
JOIN flights f
ON tf.flight_id = f.flight_id
WHERE b.book_date =
bookings.now()::date - INTERVAL '7 day'
WINDOW w AS (PARTITION BY tf.ticket_no
ORDER BY f.scheduled_departure);
SELECT passenger_name,
round( 100.0 * cnt / sum(cnt) OVER (), 2)
AS percent
FROM (
SELECT passenger_name,
count(*) cnt
FROM tickets
GROUP BY passenger_name
) t
ORDER BY percent DESC;
77
Draft as of 29-Dec-2017
WITH p AS (
SELECT left(passenger_name,
position(' ' IN passenger_name))
AS passenger_name
FROM tickets
)
SELECT passenger_name,
round( 100.0 * cnt / sum(cnt) OVER (), 2)
AS percent
FROM (
SELECT passenger_name,
count(*) cnt
FROM p
GROUP BY passenger_name
) t
ORDER BY percent DESC;
Arrays
78
Draft as of 29-Dec-2017
WITH t AS (
SELECT ticket_no,
a,
a[1] departure,
a[cardinality(a)] last_arrival,
a[cardinality(a)/2+1] middle
FROM (
SELECT t.ticket_no,
array_agg( f.departure_airport
ORDER BY f.scheduled_departure) ||
(array_agg( f.arrival_airport
ORDER BY f.scheduled_departure DESC)
)[1] AS a
FROM tickets t
JOIN ticket_flights tf
ON tf.ticket_no = t.ticket_no
JOIN flights f
ON f.flight_id = tf.flight_id
GROUP BY t.ticket_no
) t
)
SELECT t.ticket_no,
t.a,
t.departure,
CASE
WHEN t.departure = t.last_arrival
THEN t.middle
ELSE t.last_arrival
END arrival,
(t.departure = t.last_arrival) return_ticket
FROM t;
79
Draft as of 29-Dec-2017
SELECT r1.departure_airport,
r1.arrival_airport,
r1.days_of_week dow,
r2.days_of_week dow_back
FROM routes r1
JOIN routes r2
ON r1.arrival_airport = r2.departure_airport
AND r1.departure_airport = r2.arrival_airport
WHERE NOT (r1.days_of_week && r2.days_of_week);
Recursive Queries
80
Draft as of 29-Dec-2017
WITH RECURSIVE p(
last_arrival,
destination,
hops,
flights,
flight_time,
found
) AS (
SELECT a_from.airport_code,
a_to.airport_code,
array[a_from.airport_code],
array[]::char(6)[],
interval '0',
a_from.airport_code = a_to.airport_code
FROM airports a_from,
airports a_to
WHERE a_from.airport_code = 'UKX'
AND a_to.airport_code = 'CNN'
UNION ALL
SELECT r.arrival_airport,
p.destination,
(p.hops || r.arrival_airport)::char(3)[],
(p.flights || r.flight_no)::char(6)[],
p.flight_time + r.duration,
bool_or(r.arrival_airport = p.destination)
OVER ()
FROM p
JOIN routes r
ON r.departure_airport = p.last_arrival
WHERE NOT r.arrival_airport = ANY(p.hops)
AND NOT p.found
)
SELECT hops,
flights,
flight_time
FROM p
WHERE p.last_arrival = p.destination;
81
Draft as of 29-Dec-2017
82
Draft as of 29-Dec-2017
WITH RECURSIVE p(
departure,
last_arrival,
destination,
hops,
found
) AS (
SELECT a_from.airport_code,
a_from.airport_code,
a_to.airport_code,
array[a_from.airport_code],
a_from.airport_code = a_to.airport_code
FROM airports a_from,
airports a_to
UNION ALL
SELECT p.departure,
r.arrival_airport,
p.destination,
(p.hops || r.arrival_airport)::char(3)[],
bool_or(r.arrival_airport = p.destination)
OVER (PARTITION BY p.departure,
p.destination)
FROM p
JOIN routes r
ON r.departure_airport = p.last_arrival
WHERE NOT r.arrival_airport = ANY(p.hops)
AND NOT p.found
)
SELECT max(cardinality(hops)-1)
FROM p
WHERE p.last_arrival = p.destination;
83
Draft as of 29-Dec-2017
Solution.
WITH RECURSIVE p(
last_arrival,
destination,
hops,
flights,
flight_time,
min_time
) AS (
SELECT a_from.airport_code,
a_to.airport_code,
array[a_from.airport_code],
array[]::char(6)[],
interval '0',
NULL::interval
FROM airports a_from,
airports a_to
WHERE a_from.airport_code = 'UKX'
AND a_to.airport_code = 'CNN'
UNION ALL
SELECT r.arrival_airport,
p.destination,
(p.hops || r.arrival_airport)::char(3)[],
(p.flights || r.flight_no)::char(6)[],
p.flight_time + r.duration,
least(
p.min_time, min(p.flight_time+r.duration)
FILTER (
WHERE r.arrival_airport = p.destination
) OVER ()
)
FROM p
JOIN routes r
ON r.departure_airport = p.last_arrival
WHERE NOT r.arrival_airport = ANY(p.hops)
AND p.flight_time + r.duration <
coalesce(p.min_time, INTERVAL '1 year')
)
84
Draft as of 29-Dec-2017
SELECT hops,
flights,
flight_time
FROM (
SELECT hops,
flights,
flight_time,
min(min_time) OVER () min_time
FROM p
WHERE p.last_arrival = p.destination
) t
WHERE flight_time = min_time;
85
Additional Features
Full-Text Search
86
Draft as of 29-Dec-2017
87
Draft as of 29-Dec-2017
Let’s enter the text of first lectures for our courses CS301
and CS305:
88
Draft as of 29-Dec-2017
-[ RECORD 1 ]-----------------------------------------
no | I
ch_title | Databases
txt | In this chapter, we start getting acquainted
with the fascinating database world
-[ RECORD 2 ]-----------------------------------------
no | II
ch_title | First Steps
txt | Getting more fascinated with the world of
databases
-[ RECORD 3 ]-----------------------------------------
no | I
ch_title | Local Networks
txt | Here we start our adventurous journey
through the intriguing world of networks
will return the row from chapter II (but not from chapter
I, where the adjective “fascinating” is used):
-[ RECORD 1 ]-----------------------------------------
txt | Getting more fascinated with the world of
databases
89
Draft as of 29-Dec-2017
90
Draft as of 29-Dec-2017
91
Draft as of 29-Dec-2017
92
Draft as of 29-Dec-2017
The {0.1, 0.0, 1.0, 0.0} array sets the weights. It is an op-
tional argument of the ts_rank_cd function; by default,
array {0.1, 0.2, 0.4, 1.0} corresponds to D, C, B, A. The word’s
weight increases the importance of the returned row,
which helps to rank the results.
93
Draft as of 29-Dec-2017
-[ RECORD 2 ]-----------------------------------------
ts_headline | with the <b>world</b> of databases.
-[ RECORD 3 ]-----------------------------------------
ts_headline | through the intriguing <b>world</b> of
networks
94
Draft as of 29-Dec-2017
95
Draft as of 29-Dec-2017
96
Draft as of 29-Dec-2017
97
Draft as of 29-Dec-2017
98
Draft as of 29-Dec-2017
Make sure that this query only returns Nina, whose merits
are real.
99
Draft as of 29-Dec-2017
This method does not always work. Let’s try to find out
which guitars our musician Victor is playing:
name | Victor
details | { "hobbies": +
| { "guitarist": +
| { "band": "Postgressors", +
| "guitars":["Strat","Telec"] +
| } +
| } +
| }
100
Draft as of 29-Dec-2017
101
Draft as of 29-Dec-2017
102
Draft as of 29-Dec-2017
To learn more about json and jsonb types and the func-
tions that can be used with them, see PostgreSQL docu-
mentation at postgrespro.com/doc/datatype-json and
postgrespro.com/doc/functions-json.
103
PostgreSQL
for Applications
A Separate User
104
Draft as of 29-Dec-2017
The app user can work with their database without any
limitations. For example, this user can create a table:
Remote Connections
105
Draft as of 29-Dec-2017
#listen_addresses = 'localhost'
listen_addresses = '*'
106
Draft as of 29-Dec-2017
So, for our purposes, add the following line to the end of
the pg_hba.conf file:
This setting allows the app user to access the appdb data-
base from any address if the correct password is entered.
107
Draft as of 29-Dec-2017
PHP
108
Draft as of 29-Dec-2017
You can install PHP for Windows from the PHP website:
windows.php.net/download. The extension for Post-
greSQL is already included into the binary distribution,
but you must find and uncomment (by removing the semi-
colon) the following line in the php.ini file:
;extension=php_pgsql.dll
<?php
$conn = pg_connect('host=localhost port=5432 ' .
'dbname=appdb user=app ' .
'password=p@ssw0rd') or die;
$query = pg_query('SELECT * FROM greeting') or die;
while ($row = pg_fetch_array($query)) {
echo $row[0].PHP_EOL;
}
pg_free_result($query);
pg_close($conn);
?>
$ php test.php
Hello, world!
109
Draft as of 29-Dec-2017
Perl
There are several Perl builds for Windows, which are listed
at www.perl.org/get.html. ActiveState Perl and Straw-
berry Perl already include the driver required for Post-
greSQL.
use DBI;
my $conn = DBI->connect(
'dbi:Pg:dbname=appdb;host=localhost;port=5432',
'app','p@ssw0rd') or die;
my $query = $conn->prepare('SELECT * FROM greeting');
$query->execute() or die;
while (my @row = $query->fetchrow_array()) {
print @row[0]."\n";
}
$query->finish();
$conn->disconnect();
$ perl test.pl
Hello, world!
110
Draft as of 29-Dec-2017
Python
import psycopg2
conn = psycopg2.connect(
host='localhost', port='5432', database='appdb',
user='app', password='p@ssw0rd')
cur = conn.cursor()
cur.execute('SELECT * FROM greeting')
rows = cur.fetchall()
for row in rows:
print row[0]
conn.close()
$ python test.py
Hello, world!
111
Draft as of 29-Dec-2017
Java
import java.sql.*;
public class Test {
public static void main(String[] args)
throws SQLException {
Connection conn = DriverManager.getConnection(
"jdbc:postgresql://localhost:5432/appdb",
"app", "p@ssw0rd");
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(
"SELECT * FROM greeting");
while (rs.next()) {
System.out.println(rs.getString(1));
}
rs.close();
st.close();
conn.close();
}
}
112
Draft as of 29-Dec-2017
$ javac Test.java
$ java -cp .:/usr/share/java/postgresql-jdbc4.jar \
Test
Hello, world!
Backup
$ createdb appdb2
$ psql -d appdb2 -f appdb.dump
113
Draft as of 29-Dec-2017
114
Draft as of 29-Dec-2017
What’s next?
115
Draft as of 29-Dec-2017
116
Draft as of 29-Dec-2017
117
pgAdmin
pgAdmin is a popular GUI tool for administering Post-
greSQL. This application facilitates the main administra-
tion tasks, shows database objects, and allows to run SQL
queries.
Installation
118
Draft as of 29-Dec-2017
$ cd ~
$ virtualenv pgadmin4
$ cd pgadmin4
$ source bin/activate
Now let’s install pgAdmin itself. You can find the latest
available version here: www.pgadmin.org/download/
pgadmin-4-python-wheel/.
119
Draft as of 29-Dec-2017
$ cat <<EOF \
>lib/python2.7/site-packages/pgadmin4/config_local.py
import os
DATA_DIR = os.path.realpath(
os.path.expanduser(u'~/.pgadmin/'))
LOG_FILE = os.path.join(DATA_DIR, 'pgadmin4.log')
SQLITE_PATH = os.path.join(DATA_DIR, 'pgadmin4.db')
SESSION_DB_PATH = os.path.join(DATA_DIR, 'sessions')
STORAGE_DIR = os.path.join(DATA_DIR, 'storage')
SERVER_MODE = False
EOF
$ cd ~/pgadmin4
$ source bin/activate
$ python \
lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
Features
Connecting to a Server
120
Draft as of 29-Dec-2017
121
Draft as of 29-Dec-2017
Browser
In the left pane, you can see the Browser tree. As you
expand its objects, you can get to the server, which we
called LOCAL. You can see all the database it contains:
122
Draft as of 29-Dec-2017
Running Queries
123
Draft as of 29-Dec-2017
You can type the next query starting from a new line,
without deleting the previous query: just select the re-
quired code fragment before pressing F5. Thus, the whole
history of your actions will be always in front of you —
this is usually more convenient than searching for the
required query in the log on the Query History tab.
124
Draft as of 29-Dec-2017
Other
125
Documentation
and Trainings
Documentation
126
Draft as of 29-Dec-2017
Training Courses
127
Draft as of 29-Dec-2017
Topics are split in such a way that theory does not take
more than an hour. Longer time can significantly hinder
course comprehension. Practical assignments usually take
up to 30 minutes.
Duration: 3 days
128
Draft as of 29-Dec-2017
Background knowledge:
Topics:
Basic toolkit
1. Installation and management
2. Using psql
3. Configuration
129
Draft as of 29-Dec-2017
Architecture
4. PostgreSQL general overview
5. Isolation and multi-version concurrency control
6. Buffer cache and write-ahead log
Data management
7. Databases and schemas
8. System catalog
9. Tablespaces
10. Low-level details
Administration tasks
11. Monitoring
12. Maintenance
Access control
13. Roles and attributes
14. Privileges
15. Row-level security
16. Connection and authentication
Backups
17. Overview
Replication
18. Overview
130
Draft as of 29-Dec-2017
Duration: 5 days
Background knowledge:
Topics:
Introduction
1. PostgreSQL Architecture
131
Draft as of 29-Dec-2017
Logging
7. Buffer cache
8. Write-ahead log
9. Checkpoints
Replication
10. File replication
11. Stream replication
12. Switchover to a replica
13. Replication: options
Optimization basics
14. Query handling
15. Access paths
16. Join methods
17. Statistics
18. Memory usage
19. Profiling
20. Optimizing queries
Miscellaneous
21. Partitioning
22. Localization
23. Server updates
24. Managing extensions
25. Foreign data
132
Draft as of 29-Dec-2017
Duration: 4 days
Background knowledge:
SQL fundamentals.
Experience with any procedural programming lan-
guage.
Basic knowledge of Unix.
Topics:
Basic toolkit
1. Installation and management, psql
133
Draft as of 29-Dec-2017
Architecture
2. PostgreSQL general overview
3. Isolation and multi-version concurrency control
4. Buffer cache and write-ahead log
Data management
5. Logical structure
6. Physical structure
“Bookstore” application
7. Application data model
8. Client interaction with DBMS
SQL
9. Functions
10. Composite types
PL/pgSQL
11. Language overview and programming structures
12. Executing queries
13. Cursors
14. Dynamic commands
15. Arrays
16. Error handling
17. Triggers
18. Debugging
Access control
19. Overview
134
Draft as of 29-Dec-2017
Hacking PostgreSQL
135
Draft as of 29-Dec-2017
Background knowledge:
Topics:
1. Architecture overview
2. PostgreSQL community and developer tools
3. Extensibility
4. Source code overview
5. Physical data model
6. Shared memory and locks
7. Local process memory
8. Basics of query planner and executor
136
The Hacker’s
Guide to the Galaxy
News and Discussions
137
Draft as of 29-Dec-2017
Mailing Lists
138
Draft as of 29-Dec-2017
Commitfest
Conferences
139
Draft as of 29-Dec-2017
140
About the Company
The Postgres Professional company was founded in 2015,
uniting all the key Russian developers whose contribution
to PostgreSQL is recognized by the global community. It
is the Russian vendor of PostgreSQL that develops DBMS
core functionality and extensions and provides the ser-
vices in application systems engineering and support, as
well as migration to PostgreSQL.
Our address:
Tel:
+7 495 150-06-91
postgrespro.com
141
Draft as of 29-Dec-2017
Services
142
Draft as of 29-Dec-2017
143
Draft as of 29-Dec-2017
Organizing Trainings
144