PostgreSQL - basic info Flashcards

1
Q

Czym jest baza danych PostgreSQL?

A

To baza danych rozwijana na zasadach OpenSource

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Skąd wywodzi się baza danych PostgreSQL?

A

Baza danych PostgreSQL została zapoczątkowana na Uniwersytecie w Kalifornii w Berkeley przez prof. Michael’a Stonebraker’a. Był to projekt finansowany przez efense Advanced Research Projects Agency (DARPA), the Army Research Office (ARO), the National Science Foundation (NSF). The project started around 1986.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Kiedy została wypuszczona pierwsza oficjalna wersja systemu?

A

Postgres został wydany w roku 1987 i zaprezentowany w 1988 roku na konferencji ACM-SIGMOD Conference

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Skąd wzięła się nazwa PostgreSQL?

A

Projekt był kontynuację projektu Ingres - rozwijanego również przez ten sam uniwersytecki zespół. Post-gres stanowi hołd dla twórców Ingre’sa (Post-ingres). Następnie w kolejnych wersjach dodany został język SQL i nazwa uzyskała swoją obecną formę - PostgreSQL.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Kiedy Postgres zaczął być rozwijany jako projekt poza-uniwersytetem?

A

Projekt zyskał tak duża popularność, że uniwersytet nie był w pewnym momencie w stanie wspierać tak dużej i stale rosnącej liczby użytkowników. W 1995 projekt został zamknięty, a jego rozwojem zajęli się studenci (doktoranci) i przepisali bazę danych (język C) - wydając wersję Postgres95.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Jakie elementy zostały dodany w wersji Postgres95?

A

Dużo takich elementów jak język SQL, dodatkowe narzędzia graficzne, poprawa wydajności

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Kiedy powstała baza danych w obecnej postaci?

A

W roku 1996 wydana została wersja PostgreSQL - bez symbolu związanego z rokiem. Od tego czasu baza danych jest systematycznie rozwijana.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Dlaczego symbolem bazy danych jest słoń?

A

Bo słonie mają dobrą pamieć

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Jakie są zalety PostgreSQL’a?

A

1) Jest to baza OpenSource (jest jednak wersja płatna posiadająca kilka cech, który darmowa wersja nie ma)
2) PostgreSQL może funkcjonować na wielu platformach
3) PostgreSQL posiada LTS
4) PostgreSQL implementuje ACID, które są dość istotne dla tej bazy danych
5) PostgreSQL implementuje nietypowe typy danych - symulujące rozwiązania NoSQL (klucz-wartość, big table, bazy dokumentowe, bazy grafowe)
6) PostgreSQL jest zgodny ze standardem SQL (przynajmniej stara się być)
7) PostgreSQL pozwala na pisanie funkcji i procedur w różnych językach programowania
8) Mamy dostęp do kodu źródłowego
9) Zespół rozwijający PostgreSQL bardzo uważa na kompatybilność wsteczną

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Jakie wady PostgreSQL warto wspomnieć?

A

1) Nie jest to baza danych, która powinna być hostowana na Windowsie
2) Domyślna instalacja PostgreSQL wymaga modyfikacji. Jest to konfiguracja, która wyłącznie pozwala na uruchomienie się bazy danych.
3) Kosz administracji PostgreSQL bywa wyższy
4) Administracja serwerem wymaga wiedzy na temat Linux’a i odbywa się dosyć niskopoziomowo.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Jaki model PostgreSQL wykorzystuje w swojej architekturze pod kątem pracy równoległej?

A

PostgreSQL wykorzystuje wiele procesów (a nie wiele wątków). Z tego powodu niektóre narzędzia diagnostyczne mogą pokazywać informacje o tym, że uruchomionych jest wiele różnych wersji PostgreSQL.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Jakie procesy możemy wyróżnić w przypadku PostgreSQL’a?

A

postmaster process Multiple postgres processes, one for each connection
WAL writer process
background writer process
checkpointer process
autovacuum launcher process (optional)
logger process (optional)
archiver process (optional)
stats collector process (optional)
WAL sender process (if Streaming Replication is active) WAL receiver process (if Streaming Replication is active)
background worker processes (if a query gets parallelised, which is available since 9.6)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Opisz w jaki sposób następuje przetwarzania i obsługa połączenia do bazy danych PostgreSQL?

A

How Data is processed
Connecting to the Instance
Client applications, which run on a different server than the instance, use the IP protocol to connect to it. If client application and instance run on the same server, the same connection method is possible. But it is also possible to use a connection via a local socket.

In a first step the application connects to the postmaster process. The postmaster checks the application’s rights and - if successful - starts a new postgres process and connects it with the client application.

Accessing Data
Client processes send and request data to and from the instance. For performance reasons, the instance doesn’t write or read the requested data directly to or from disk files. Instead, it buffers them in a shared memory area which is called the shared buffers. The flushing to disc is done at a later stage.

To perform a client request, the corresponding postgres process acts on the shared buffers and WAL buffers and manipulates their contents. When the client requests a COMMIT, the WAL writer process writes and flushes all WAL records resulting from this transaction to the WAL file. As the WAL file - in contrast to the data files - is written strictly sequentially, this operation is relatively fast. After that, the client gets its COMMIT confirmation. At this point, the database is inconsistent, which means that there are differences between shared buffers and the corresponding data files.

Periodically the background writer process checks the shared buffers for ‘dirty’ pages and writes them to the appropriate data files. ‘Dirty’ pages are those whose content was modified by one of the postgres processes after their transfer from disk to memory.

The checkpointer process also runs periodically, but less frequently than the background writer. When it starts, it prevents further buffer modifications, forces the background writer process to write and flush all ‘dirty’ pages, and forces the WAL writer to write and flush a CHECKPOINT record to the WAL file after which the database is consistent, which means: a) the content of the shared buffers is the same as the data in the files, b) all modifications of WAL buffers are written to WAL files, and c) table data correlates with index data. This consistency is the purpose of checkpoints.

In essence the instance contains at least the three processes WAL writer, background writer, and checkpointer - and one postgres process per connection. In most cases there are some more processes running.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Jakie są dodatkowe procesy wykorzystywane przez bazę danych PostgreSQL?

A

Optional Processes
The autovacuum launcher process starts a number of worker processes. They remove superflous row versions according to the MVCC architecture of PostgreSQL. This work is done in shared memory and the ‘dirty’ pages are written to disc in the same way as any other ‘dirty’ pages, such as the ones resulting from data modification by clients.

The logger process writes log, warning, and error messages to a log file (not to the WAL file!).

The archiver process copies WAL files, which are completely filled by the WAL writer, to a configurable location for mid-term storing.

The stats collector process continuously collects information about the number of accesses to tables and indices, total number of rows in tables, and works in coordination with VACUUM/ANALYZE and ANALYZE.

The WAL sender and WAL receiver processes are part of the Streaming Replication feature. They exchange data about changes in the master server bypassing the WAL files on disc.

Since version 9.6 it is possible to execute queries in parallel on several CPUs. In this case those parts of the execution plan, which shall run in parallel, are executed by additional background worker processes. They have access to the shared buffers in the same way as the original postgres processes and handle different buffer pages at the same time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Czy PostgreSQL używa architektury MVCC i co to oznacza?

A

MVCC (MultiVersion Concurrency Control) oznacza, że PostgreSQL pozwala na modyfikowanie danych i ich równoczesny odczyt przez wielu użytkowników. Oznacza to, że w tym samym momencie może istnieć wiele wersji danego rekordu - widzialnego dla różnego rodzaju transakcji.
Minusem tego rozwiązania jest konieczność utrzymywania wielu wersji tych samych danych. Z drugiej strony zwiększa to możliwość odczytu danych przez wielu użytkowników.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Dlaczego PostgreSQL jest trudniejszy w administracji?

A

W celu poprawnej administracji systemami bazującymi na PostgreSQL wymagana jest znajomość serwerów Linux i umiejętność niskopoziomowej pracy z bazami danych (z uzyciem konsoli).

17
Q

Jak nazywa się podstawowe niskopoziomowe narzędzie, które pozwala nam na pracę z serwerem PostgreSQL?

A

psql