aboutsummaryrefslogtreecommitdiff
path: root/doc/src/sgml/arch-pg.sgml
blob: 21dbf58685eeebb7931357dcbe9b109fe8cbda9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<Chapter Id="arch-pg">
	<TITLE>Architecture</TITLE>

<Sect1 id="arch-pg-concepts">
<Title><ProductName>PostgreSQL</ProductName> Architectural Concepts</Title>

<Para>
     Before we begin, you  should  understand  the  basic
     <ProductName>PostgreSQL</ProductName>  system  architecture.   Understanding how the
     parts of <ProductName>PostgreSQL</ProductName> interact will make the  next  chapter
     somewhat clearer.
     In  database  jargon,  <ProductName>PostgreSQL</ProductName> uses a simple "process  
     per-user" client/server model.  A <ProductName>PostgreSQL</ProductName> session 
     consists of the following cooperating Unix processes (programs):

<ItemizedList>
<ListItem>
<Para>
      	A supervisory daemon process (the <Application>postmaster</Application>),
</Para>
</ListItem>
<ListItem>
<Para>
      	the user's frontend application (e.g., the <Application>psql</Application> program), and
</Para>
</ListItem>
<ListItem>
<Para>
      	one or more backend database servers (the <Application>postgres</Application> process itself).
</Para>
</ListItem>
</ItemizedList>
</para>
<Para>
     A single  <Application>postmaster</Application>  manages  a  given  collection  of
     databases  on  a  single  host.   Such  a collection of
     databases is called a cluster (of databases).   A frontend
     application  that  wishes  to  access  a  given database
     within a cluster makes calls to an interface library (e.g., <application>libpq</>)
     that is linked into the application.
     The library sends user requests over the network to the
     <Application>postmaster</Application>
(<XRef LinkEnd="PGARCH-CONNECTIONS">(a)), 
which in turn  starts  a  new backend  server  process 
(<XRef LinkEnd="PGARCH-CONNECTIONS">(b)) 
     
<figure id="PGARCH-CONNECTIONS">
 <title>How a connection is established</title>

 <mediaobject>
  <imageobject>
   <imagedata align="center" fileref="connections">
  </imageobject>
 </mediaobject>
</figure>

     and connects the frontend process to the new server 
(<XRef LinkEnd="PGARCH-CONNECTIONS">(c)).
From that  point  on,  the  frontend process and the backend
     server communicate without intervention by the 
     <Application>postmaster</Application>.   Hence, the <Application>postmaster</Application> is always running, waiting
     for connection requests, whereas frontend  and  backend  processes
     come  and  go.  The <FileName>libpq</FileName> library allows a single 
     frontend to make multiple connections to backend processes.
     However,  each backend process is a single-threaded process that can
     only execute one query at a time; so the communication over any one
     frontend-to-backend connection is single-threaded.
</Para>

<Para>
     One  implication of this architecture is that the 
     <Application>postmaster</Application> and the backend always run on the
     same machine (the  database  server), while the frontend 
     application may run  anywhere.   You  should  keep  this  
     in  mind,
     because  the  files  that  can  be accessed on a client
     machine may not be accessible (or may only be  accessed
     using  a  different  path name)  on  the database server
     machine.
</Para>

<Para>
     You should also be aware that the <Application>postmaster</Application> and
     <application>postgres</>  servers  run  with  the  user ID  of the <ProductName>PostgreSQL</ProductName>
     <quote>superuser</>.
Note that the <ProductName>PostgreSQL</ProductName> superuser does not
have  to  be  any particular user (e.g., a user named 
<literal>postgres</literal>), although many systems are installed that way.
Furthermore,  the  <ProductName>PostgreSQL</ProductName>  superuser should
definitely  not  be the Unix superuser, <literal>root</literal>!
It is safest if the <ProductName>PostgreSQL</ProductName>  superuser is an
ordinary, unprivileged user so far as the surrounding Unix system is
concerned.
     In any case, all files relating to a database should belong to
     this <ProductName>Postgres</ProductName> superuser.
</Para>
</sect1>
</Chapter>

<!-- Keep this comment at the end of the file
Local variables:
mode:sgml
sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-tabs-mode:nil
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"./reference.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:("/usr/share/sgml/catalog")
sgml-local-ecat-files:nil
End:
-->