Tips_sql   >   Postgresql   >   PostgreSQL (All Contents)
This section covers various tips related to setting up and working with PostgreSQL from the perspective of an Omnis Studio programmer. I started using PostgreSQL in 2007 after talking to another Omnis Studio developer who was very happy with PostgreSQL and was using against some sizeable databases. (over a million records in some tables)
I had resisted using PostgreSQL because Omnis Studio did not have a DAM for connecting to PostgreSQL. That changed with Omnis Studio version 4.3 so I figured it was worth a try. The claim for PostgreSQL as opposed to MySQL is that PG was built from the ground up with all the features and then tuned for performance later on, whereas the MySQL was built for speed and then the features (transactions, stored procedures, etc.) were added afterwards.
With the files and instructions from another Omnis Studio developer (Dave McKeone of Artsman) I installed and on my MacBook Pro laptop in less than 15 minutes. It would have taken me many hours of struggling and searching for answers using Google to get it right on my own. If you want to install PoistgreSQL on a Mac, see the topic on .This section covers the steps involved with installing and configuring PostgreSQL on Mac OS X.
Thanks to Dave McKeone from the good guys at Artsman for providing this information.Before installing PostgresSQL you should add a postgres user to your computer's accounts. The installer will install one for you, but then you will have difficulty setting or changing the postgres user password.
After adding the postgres user, check the NetInfo settings as follows:
From the Utilities folder.
If you are in column view, press the left arrow key, then type n to scroll down to NetInfo Manager, then press Cmnd+down arrow to open the application.)
Get the following files off the internet and install them on your Mac OS X computer. (As of PostgreSQL 8)
You need to set up a .bash_profile file as follows:
export PATH=/Library/PostgreSQL8/bin:$PATH
export PGDATA=/Library/PostgreSQL8/data
You need to change the Shared Memory Settings. This is done so that you can increase the shared_buffers parameter to greater than the standard 8MB. Shared buffers allow PostgreSQL to use much more memory and can improve performance quite dramatically.
Set up a sysctl.conf file as follows:
kern.sysv.shmmax=524288000
kern.sysv.shmmin=1
kern.sysv.shmmni=64
kern.sysv.shmseg=16
kern.sysv.semmns=130
kern.sysv.shmall=131072000
kern.sysv.maxproc=2048
kern.maxprocperuid=512
shmmax is the key setting; it is in bytes. The value in this example is 500MB. If the machine has more memory to use, then this should be increased as well. shmall is the shmmax setting divided by 4.
1 MB = 1048576 bytes
This file controls all access to the PostgreSQL server. In order for clients to connect to the server their IP address must be in the allowed list of users. The two common methods that you will see being used are md5 and trust. Md5 does md5 password authentication and should be used for just about all entries to this file. Trust allows clients to connect without password authentication, the only entry trust should ever have is for the local server machine.
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 192.168.1.0/24 md5
# IPv6 local connections:
host all all ::1/128 trust
NOTE:The CIDR address as noted above has many combinations. Here is an example of the common one's you will see:
192.168.150.50 = 192.168.150.50/32
192.168.150.XXX = 192.168.150.0/24
192.168.XXX.XXX = 192.168.0.0/16
192.XXX.XXX.XXX = 192.0.0.0/8
XXX.XXX.XXX.XXX = 0.0.0.0/0 (This allows everything... probably should never use that)
On OS X parameters that have a # character in front of them are considered not in use. If a parameter that is required has one of these in front, remove the # character before change the setting.
The following are common properties you may want to verify/change:
1 MB = 1048576 bytes
I recommend that you stop and start the PostgreSQL database server once you've got all the configuration stuff done. If there are any errors in starting the server it will be reported to you and you can solve the problem before you go any further.
To stop and start the server from the command line:
Use the pgAdmin tool to create new databases.
Use the pgAdmin tool to drop a database.
To backup a database from the command line on Mac OS X:
[Database] is replaced with the database name.
[Path] is the path where you want to backup to go including the file name and extension.
For uncompressed use the file extension .sql
For compressed use the file extension .backup
Compressed backup example for the database 'Demo' as follows:
e.g For Database 'Demo' -> pg_dump -U postgres -o Demo > /Users/Shared/MyBackups/Demo.sql
To backup a database from the command line on Mac OS X:
[Database] is replaced with the database name.
[Path] is the path where you want to backup to go including the file name and extension.
Uncompressed:
e.g For Database 'Demo' -> psql Demo < /Users/Shared/MyBackups/Demo.sql
This section covers the steps involved with installing and configuring PostgreSQL on Mac OS X.
I have not installed PostgreSQL on Windows... so I can't give you directions. If you have the steps documented please email them to me. doug@vencor.ca