Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 3451AB5D91F for ; Sun, 15 May 2011 19:02:57 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 31851-03 for ; Sun, 15 May 2011 22:02:46 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mailserver.dialdata.com.ar (dialdata.com.ar [200.49.210.5]) by mail.postgresql.org (Postfix) with ESMTP id 021CBB5D80B for ; Sun, 15 May 2011 19:02:45 -0300 (ADT) Received: from mailserver.dialdata.com.ar (localhost [127.0.0.1]) by mailserver.dialdata.com.ar (Postfix) with ESMTP id F2D4D2E71B for ; Sun, 15 May 2011 19:02:39 -0300 (ART) Received: from 190-49-178-152.speedy.com.ar ([190.49.178.152]) by mailserver.dialdata.com.ar:81 with HTTP (HTTP/1.1 POST); Sun, 15 May 2011 19:02:39 -0300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=_9226a410948db25ed35cd74866ab8a0a" Date: Sun, 15 May 2011 19:02:39 -0300 From: Ezequiel Lovelle To: Subject: slow loop =?UTF-8?Q?inserts=3F?= Organization: Teleservicios y Marketing S.A Message-ID: <284696193619d8ac712400941bc5946c@dialdata.com.ar> X-Sender: elovelle@dialdata.com.ar User-Agent: DDM/0.5 X-DDM-MailScanner-Information: DDM X-DDM-MailScanner-ID: F2D4D2E71B.A1567 X-DDM-MailScanner: Found to be clean X-DDM-MailScanner-From: elovelle@dialdata.com.ar X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.509 tagged_above=-10 required=5 tests=BAYES_05=-0.5, HTML_MESSAGE=0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201105/227 X-Sequence-Number: 43736 --=_9226a410948db25ed35cd74866ab8a0a Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=UTF-8 Hi, I'm new to postgres and I have the next question. I have a php program that makes 100000 inserts in my database. autoincrement numbers inserted into a table with 5 columns. The script takes about 4 minutes from a webserver Is it a normal time? How could reduce this time by a bulce of inserts? When I turn off fsync get much more performance, but it is not ideal in power failure HARDWARE: 2 disks 1TB 7200 rpm with software raid 1 (gmirror raid) 8 Gb RAM CPU Intel Quad Core 2.4 Ghz OS: Freebsd 8.2 POSTGRES VERSION: 9.0.4 MY POSTGRES CONFIG: listen_addresses = '*' wal_level = archive fsync = on archive_mode = on archive_command = 'exit 0' maintenance_work_mem = 480MB checkpoint_completion_target = 0.5 effective_cache_size = 5632MB work_mem = 40MB wal_buffers = 16MB checkpoint_segments = 30 shared_buffers = 1920MB max_connections = 40 MY EXECUTION TIME OF MY SCRIPT: [root@webserver ~]# time php script.php real 4m54.846s user 0m2.695s sys 0m1.775s MY SCIPT: --=_9226a410948db25ed35cd74866ab8a0a Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=UTF-8

Hi, I'm new to postgres and I have the next question.

I have a php program that makes 100000 inserts in my database.
aut= oincrement numbers inserted into a table with 5 columns.
The script t= akes about 4 minutes from a webserver
Is it a normal time?

How could reduce this time by a bulce of inserts?

When I turn off fsync get much more performance, but it is not ideal in = power failure

 

Hardware: 2 disks 1TB 7200 rpm with software raid 1 (gm= irror raid)

8 Gb RAM

CPU Intel Quad Core 2.4 Ghz

OS: Freebsd 8.2

Postgres version: 9.0.4

 

My postgres config:


listen_addresses =3D '*'
wal_level =3D archive
fsync = =3D on
archive_mode =3D on
archive_command =3D 'exit 0'
m= aintenance_work_mem =3D 480MB
checkpoint_completion_target =3D 0.5 effective_cache_size =3D 5632MB
work_mem =3D 40MB
wal_buffe= rs =3D 16MB
checkpoint_segments =3D 30
shared_buffers =3D 1920M= B
max_connections =3D 40

 

My execution time of my script:

[root@webserver ~]# time php script.php

real  &nb= sp; 4m54.846s
user    0m2.695s
sys  &n= bsp;  0m1.775s

 

My scipt:

<?php

pg_connect("host=3Dhost  port=3Dport dbname=3Ddb user=3Duser passwo= rd=3Dpass") or die ("No me conecto...");
for ( $var =3D 1; $var <= =3D 100000 ; $var++ )
{
$sql =3D "INSERT INTO server (aa, bb, c= c, dd, ee) VALUES ('$var','$var','$var','$var','$var')";
pg_query($sq= l);
}
?>

my dd test is:

#time sh -c "dd if=3D/dev/zero of=3D/tmp/test count=3D500000 && = fsync"
500000+0 records in
500000+0 records out
256000000= bytes transferred in 2.147917 secs (119185237 bytes/sec)
usage: fsyn= c file ...

real    0m2.177s
user &nb= sp;  0m0.188s
sys     0m0.876s

 

Thanks, any help will be well recived,

--=_9226a410948db25ed35cd74866ab8a0a--