Re: PostgreSQL vs MySQL : strange results on insertion

From: Mario Weilguni <mweilguni(at)sime(dot)com>
To: fpaul(at)netcourrier(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: PostgreSQL vs MySQL : strange results on insertion
Date: 2002-09-05 18:39:55
Message-ID: 200209052039.55179.mweilguni@sime.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> Time to realize 10000 insertions with PostgreSQL:
> $time ./test_postgresql
>
> real 0m28.568s
> user 0m0.390s
> sys 0m0.270s
> (between 28 and 30 seconds !!!.... )
>
> Very strange, isn't it ? Is there something in PostgreSQL's C API that I
> didn't understand ? Subtleties during the configuration ? I do not want to
> believe that PostgreSQL is 15 times slower than MySQL ! Thank you for any
> comment, remark and correction!

On my system (compiled for profiling, debugging and slow disk) it takes 2 minutes without transactions, and 4.5 seconds with transactions:

#include <stdio.h>
#include <libpq-fe.h>

#define INSERTION "INSERT INTO test (type_int, type, type_int2, type_text) VALUES (%d,\'essai de chaine decaractère\',100,\'MAJUSCULES et minuscules\')"

int main(int argc, char **argv) {
PGconn *conn;
unsigned int i;
char mquery[1000];
PGresult *res;

conn=PQconnectdb("dbname=mario");
if (PQstatus(conn) == CONNECTION_OK) {
res=PQexec(conn,"begin");
PQclear(res);
for (i=0;i<=10000;i++) {
sprintf(mquery,INSERTION,i);
res=PQexec(conn,mquery);
if (PQresultStatus(res)!= PGRES_COMMAND_OK) {
printf("sql query error (%s) : %s\n",
mquery,PQresultErrorMessage(res));
PQclear(res);
res=PQexec(conn,"commit ");
PQclear(res);
PQfinish(conn);
return 0;
}
}
PQclear(res);
PQfinish(conn);
}
else {
printf("sql connection error :%s\n",PQerrorMessage(conn));
return 0;
}
return 0;
}

best regards,
mario weilguni

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Steve 2002-09-05 18:41:03 Literal '-' in regular expression bracket sets
Previous Message Steve 2002-09-05 18:39:26 Literal dash in regular expression brackets