Forum Moderators: open

Message Too Old, No Replies

mysql or postgresql

wich one to use and why

         

DoppyNL

10:14 am on Oct 26, 2005 (gmt 0)

10+ Year Member



lately I've been hearing and reading all over the place that postgresql is better then mysql and that one is better or something.

Why is that?
Wich one is better and why?
Or wich one is better in what area?
Should I switch?

To make the question simple:
What are the pro's and cons for mysql en postgresql?

FourDegreez

9:22 pm on Nov 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For awhile, it was postgresql that supported more advanced features, like transactions, certain constraints or indexes, sub-queries, etc. I think that the conventional wisdom is that mysql has caught up in a lot of areas, although it may still lag behind.

Also, the old conventional wisdom is that mysql is faster per query but postgresql holds up better under a higher load. Not sure if that distinction still exists.

I tend to see postgresql as a more "serious" database, and to be honest I rather like it. But mysql is so standard on most hosting packages that I just use it for the simple things I've needed to do, and haven't had a problem. I haven't bothered to explore the differences in a long time because I haven't had the need.

txbakers

3:40 am on Nov 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



both are excellent. there is more documentation and support available for mySQL.

DoppyNL

8:12 am on Nov 12, 2005 (gmt 0)

10+ Year Member



I allready know mySQL for quite some time.
So now I've been playing with postgres for a short time now.

I have to conclude that postgres is a little more mature. Not that mySQL isn't working properly, it's just that postgres seems to be a little more quality.

It seems indeed that postgres is also a little slower then mysql, but I haven't tested that yet properly. Could also be that my php-code is a bit slower for other reasons.

I'm using phppgadmin as a interface with postgres, the user interface of that could be greatly improved, several actions don't feel intuitive.

Also, a question for postgres-users:
What is better practice in postgres:
- use the oid as the key of a records, since that allready is unique.
- use a sequence in combination with an integer field.
I think the latter, as in phppgadmin it seems not possible to make "oid" a primary key...

py9jmas

10:46 am on Nov 12, 2005 (gmt 0)

10+ Year Member



Use a sequence and an integer column. From PostgreSQL 8's release notes, under E.5.3. Deprecated Features,
By default, tables in PostgreSQL 8.0 and earlier are created with OIDs. In the next release, this will not be the case: to create a table that contains OIDs, the WITH OIDS clause must be specified or the default_with_oids configuration parameter must be set. Users are encouraged to explicitly specify WITH OIDS if their tables require OIDs for compatibility with future releases of PostgreSQL.

[postgresql.org...]

DoppyNL

12:15 pm on Nov 12, 2005 (gmt 0)

10+ Year Member



I'm allready using OIDS and a field `id` with a sequence that is also a primary key.

Not sure if this is a correct place to ask this, but here goes.

What would be the best method to get the primary key of a record that was just inserted using an insert-query, when working with PHP.

I'm currently doing it like this.
Table has OIDS and a field `id` with a sequence.
I run the insert query.
use the function pg_last_oid() to get the oid.
run a select-query with the oid in the where-condition to fetch the field `id`.

Or is there some other method that is better practice?

tnx :)