1 (edited by Frank H 2005-05-28 12:39)

Topic: PostgreSQL: Anyone using it that have a few tips?

Well, after several years of MySQL I've come to the point that it no longer supports my demands ... and PostgreSQL seems to do it, so I've installed another database engine on my webserver to cope with a project I'm doing (non PunBB related, but there seems to be a good bunch of people in here)... (I need ACID, which at least has been a no priority for mysql, and also the fact that PostgreSQL has arrays in the columns, well it makes the move from mysql not that hard (I'm not comparing performance, I just need a stable thing where I can 'trust' the queries are done in a proper manner) ... and some things I can most probably do as functions in postgre instead of taking stuff out and then putting stuff back in, feels a bit more solid)

Either way, I'm just wondering if anyone here has good knowledge with PostgreSQL and if so, any nice tips/urls you have that can be useful? (mostly about stuff beeing made in a different way than mysql) ...

Thnx in advance

Re: PostgreSQL: Anyone using it that have a few tips?

Found this page today, it somewhat gives a hint on why I'm trying to look for alternatives to mysql, been working on Oracle the last few weeks, and I've been questioning mysql on my system more and more ... http://openacs.org/philosophy/why-not-mysql.html

Re: PostgreSQL: Anyone using it that have a few tips?

MySQL has no subqueries.
Instead of performing one complex query that is entirely processed on the database end, MySQL users have to perform 2 or more serial queries that each must go over inter-process or network communication between the app and the database. This significantly reduces the speed advantages of MySQL.

they have that now

An enterprise-level system will never compromise certain features for speed.

is mysql really trying to be an enterprise level system?

4 (edited by dchan 2005-05-29 19:59)

Re: PostgreSQL: Anyone using it that have a few tips?

I've been using PostgreSQL since 1997, when I wrote a support ticket web app using Perl and Postgresql.  I remember having to use gcc to compile the interface module to use PostgreSQL for CGI.  Once the Perl libs showed up I never looked at c-based CGI ever again.

If you're installing the current version PostgreSQL don't bother tinkering under the hood too much. It's easy to give PostgeSQL too much power, its setup to handle about anything you want to do with it unless you're working on something that wickedly parallel (clustered/sync'd/and nested joining up the wazoo).

Anyone using PostgreSQL should only have to do the two following tasks daily:

1)setup an scheduled backup

2)setup a scheduled vacuum

Here's some crontab examples:

30 4 * * * /home/db_su_name/scripts/dbroller 2>&1
* 3 * * * /usr/bin/vacuumdb -q -d punbb 2>&1

Here's the code I use for a database backup. Basically you add the name of any of the databases you want to keep a backup of into the array. Converting this to run with the database name passed as an argument is a trivial exercise.

#!/usr/bin/perl

$dbFileFilter="%s.%s";

my @dbName=("punbb","template1");

foreach $db(@dbName){

        $dbFile  = sprintf "$dbFileFilter",$db,"sql";
        $rslt=`pg_dump $db > ~db_su_name/pgData/$dbFile`;
}

I also use the logrotate daemon to do my bidding...basically keeping me from having a buttload of database files hanging around. If you are running a "snapshot" service, then this isn't for you.  The benefits of this are a limited number of database files are kept and you can set how much backstepping you want to do.

In the /etc/logrotate.d/ folder I create a file called "pg-bak"

/home/pg_su_name/pgData/*.sql
{
    rotate 7
    daily
    missingok
    compress
}

This means I keep 7 days of compressed backups.

Combine this with rsync to an offsite server and your bases are covered.

I cannot overstate the performance gains you will get from performing a vacuum on the punbb database once a day. PostgreSQL was loading the server pretty high until I started doing a daily vacuum.

Re: PostgreSQL: Anyone using it that have a few tips?

thanks smile

does the vacuum clean up 'old internal caches' and stuff?

6

Re: PostgreSQL: Anyone using it that have a few tips?

Frank H wrote:

thanks smile

does the vacuum clean up 'old internal caches' and stuff?

de re postgresql vacuum

Re: PostgreSQL: Anyone using it that have a few tips?

hehe ... the manual wink

Re: PostgreSQL: Anyone using it that have a few tips?

There is also many contribs, and one interesting : auto vaccum. It makes regular vacuums when needed. I use it on my site (http://www.jdr-delain.net : 800 000 queries/day) and it works fine.

Re: PostgreSQL: Anyone using it that have a few tips?

ah ok, sounds like it could be useful smile

Re: PostgreSQL: Anyone using it that have a few tips?

Frank H: You should read the top of the document you linked to:

This Document was written in May 2000. Thus, it is outdated and does not represent the latest data concerning MySQL.

2000! That's a very, very long time in this business smile

"Programming is like sex: one mistake and you have to support it for the rest of your life."