X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5C352D9A80 for ; Wed, 28 Sep 2005 09:27:41 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 94838-03 for ; Wed, 28 Sep 2005 12:27:31 +0000 (GMT) Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.202]) by svr1.postgresql.org (Postfix) with ESMTP id 3A8E0D9A93 for ; Wed, 28 Sep 2005 09:27:32 -0300 (ADT) Received: by xproxy.gmail.com with SMTP id i30so1467487wxd for ; Wed, 28 Sep 2005 05:27:37 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=EBmqXakAEXHu0SB9IrKEHxJUpCPBjyMtSRd/S1KdPi6mU25i/ylXxxUqwl/DdQyyU3gJNVO/VzaYwmu8Ff9wno8ZYVkGrWV6XnsRq2iaptCsJnZ1legyhLYtb9EgcreIb3dk//xK8HJcyqaHYdcDuTP4oSM115sBc8i+0+bPI/E= Received: by 10.70.102.12 with SMTP id z12mr3447356wxb; Wed, 28 Sep 2005 05:27:37 -0700 (PDT) Received: by 10.70.75.4 with HTTP; Wed, 28 Sep 2005 05:27:36 -0700 (PDT) Message-ID: Date: Wed, 28 Sep 2005 17:57:36 +0530 From: Rajesh Kumar Mallah Reply-To: Rajesh Kumar Mallah To: pgsql-performance@postgresql.org Subject: Slow concurrent update of same row in a given table MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.398 required=5 tests=[AWL=-0.458, RCVD_BY_IP=0.024, RCVD_IN_BL_SPAMCOP_NET=1.832] X-Spam-Level: * X-Archive-Number: 200509/388 X-Sequence-Number: 14696 Hi While doing some stress testing for updates in a small sized table we found the following results. We are not too happy about the speed of the updates particularly at high concurrency (10 clients). Initially we get 119 updates / sec but it drops to 10 updates/sec as concurrency is increased. PostgreSQL: 8.0.3 ------------------------------- TABLE STRUCTURE: general.stress ------------------------------- | dispatch_id | integer | not null | | query_id | integer | | | generated | timestamp with time zone | | | unsubscribes | integer | | | read_count | integer | | | status | character varying(10) | | | bounce_tracking | boolean | | | dispatch_hour | integer | | | dispatch_date_id | integer | | +------------------+--------------------------+-----------+ Indexes: "stress_pkey" PRIMARY KEY, btree (dispatch_id) UPDATE STATEMENT: update general.stress set read_count=3Dread_count+1 where dispatch_id=3D114 TOOL USED: Perl/DBI , with prepared statement handlers CONCURRENCY METHOD: executing multiple copies of same program from different shells (linux enviornment) CLIENT SERVER LINK : 10/100 Mbits , LAN CLIENT CODE: stress.pl ------------------------------------------------------------------------- #!/opt/perl/bin/perl -I/usr/local/masonapache/lib/perl ################################################ #overview: update the table as fast as possible (while(1){}) #on every 100th commit , print the average update frequency #of last 100 updates ########################################## use strict; use Time::HiRes qw(gettimeofday tv_interval); use Utils; my $dbh =3D &Utils::db_connect(); my $sth =3D $dbh -> prepare("update general.stress set read_count=3Dread_count+1 where dispatch_id=3D114"); my $cnt=3D0; my $t0 =3D [ gettimeofday ]; while(1) { $sth -> execute(); $dbh->commit(); $cnt++; if ($cnt % 100 =3D=3D 0) { my $t1 =3D [ gettimeofday ]; my $elapsed =3D tv_interval ( $t0 , $t1 ); $t0 =3D $t1; printf "Rate: %d updates / sec\n" , 100.0/$elapsed ; } } $sth->finish(); $dbh->disconnect(); ---------------------------------------------------------------------------= ----------- ---------------------------------------------------------------------------= ----------- RESULTS: ---------------------------------------------------------------------------= ----------- Number of Copies | Update perl Sec 1 --> 119 2 ---> 59 3 ---> 38 4 ---> 28 5 --> 22 6 --> 19 7 --> 16 8 --> 14 9 --> 11 10 --> 11 11 --> 10 ---------------------------------------------------------------------------= ---------- Note that the table was vacuum analyzed during the tests total number of records in table: 93 ---------------------------------------------------------------------------= ---------- Regds Rajesh Kumar Mallah.