Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id A48EEB5DBDA for ; Tue, 24 May 2011 02:24:56 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 73572-02 for ; Tue, 24 May 2011 05:24:49 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-yx0-f174.google.com (mail-yx0-f174.google.com [209.85.213.174]) by mail.postgresql.org (Postfix) with ESMTP id 4267CB5DBF0 for ; Tue, 24 May 2011 02:24:48 -0300 (ADT) Received: by yxs7 with SMTP id 7so2432954yxs.19 for ; Mon, 23 May 2011 22:24:48 -0700 (PDT) Received: by 10.101.38.2 with SMTP id q2mr4313026anj.121.1306214688203; Mon, 23 May 2011 22:24:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.108.5 with HTTP; Mon, 23 May 2011 22:24:28 -0700 (PDT) In-Reply-To: References: From: Terry Schmitt Date: Mon, 23 May 2011 22:24:28 -0700 Message-ID: Subject: Re: Performance degradation of inserts when database size grows To: pgsql-performance@postgresql.org Content-Type: multipart/alternative; boundary=001636ed71a27da3b404a3fece81 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.899 tagged_above=-10 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201105/320 X-Sequence-Number: 43829 --001636ed71a27da3b404a3fece81 Content-Type: text/plain; charset=ISO-8859-1 As near as I can tell from your test configuration description, you have JMeter --> J2EE --> Postgres. Have you ruled out the J2EE server as the problem? This problem may not be the database. I would take a look at your app server's health and look for any potential issues there before spending too much time on the database. Perhaps there are memory issues or excessive garbage collection on the app server? Terry On Tue, May 17, 2011 at 5:45 AM, Andrey Vorobiev < andrey.o.vorobiev@gmail.com> wrote: > Hi, guys. > > > I have following environment configuration > > - Postgres 8.4.7 with following postresql.conf settings modified: > > listen_addresses = '*' > > max_connections = 100 > > > shared_buffers = 2048MB > > max_prepared_transactions = 100 > > wal_buffers = 1024kB > > > checkpoint_segments = 64 > > checkpoint_completion_target = 0.8 > > > log_checkpoints = on > > > - Two databases. Let's call them db_1 and db_2 > > - J2EE application server that performs inserts into databases defined > above. (distribution transactions are used). > > - All constraints and indexes are on. > > - JMeter that acts as HTTP client and sends requests to server causing it > to insert rows. (case of new users registration) > > > After running scenario scenario described above (with 10 concurrent > threads) I have observed following behavior: > > > For the first time everything is fine and J2EE server handles about 700 > requests/sec (about 2500 inserts into several tables per second). But after > some amount of time I observe performance degradation. In general it looks > like the following: > > > Total number of requests passed; Requests per second; > > 382000; 768; > > 546000; 765; > > 580000; 723; > > 650000; 700; > > 671000; 656; > > 700000; 628; > > > Checkpoint logging gives me the following: > > 2011-05-17 18:55:51 NOVST LOG: checkpoint starting: xlog > > 2011-05-17 18:57:20 NOVST LOG: checkpoint complete: wrote 62861 buffers > (24.0%); 0 transaction log file(s) added, 0 removed, 0 recycled; > write=89.196 s, sync=0.029 s, total=89.242 s > > 2011-05-17 18:57:47 NOVST LOG: checkpoint starting: xlog > > 2011-05-17 18:59:02 NOVST LOG: checkpoint complete: wrote 83747 buffers > (31.9%); 0 transaction log file(s) added, 0 removed, 64 recycled; > write=75.001 s, sync=0.043 s, total=75.061 s > > 2011-05-17 18:59:29 NOVST LOG: checkpoint starting: xlog > > 2011-05-17 19:00:30 NOVST LOG: checkpoint complete: wrote 97341 buffers > (37.1%); 0 transaction log file(s) added, 0 removed, 64 recycled; > write=60.413 s, sync=0.050 s, total=60.479 s > > 2011-05-17 19:00:55 NOVST LOG: checkpoint starting: xlog > > 2011-05-17 19:01:48 NOVST LOG: checkpoint complete: wrote 110149 buffers > (42.0%); 0 transaction log file(s) added, 0 removed, 64 recycled; > write=52.285 s, sync=0.072 s, total=52.379 s > > 2011-05-17 19:02:11 NOVST LOG: checkpoint starting: xlog > > 2011-05-17 19:02:58 NOVST LOG: checkpoint complete: wrote 120003 buffers > (45.8%); 0 transaction log file(s) added, 0 removed, 64 recycled; > write=46.766 s, sync=0.082 s, total=46.864 s > > 2011-05-17 19:03:20 NOVST LOG: checkpoint starting: xlog > > 2011-05-17 19:04:18 NOVST LOG: checkpoint complete: wrote 122296 buffers > (46.7%); 0 transaction log file(s) added, 0 removed, 64 recycled; > write=57.795 s, sync=0.054 s, total=57.867 s > > 2011-05-17 19:04:38 NOVST LOG: checkpoint starting: xlog > > 2011-05-17 19:05:34 NOVST LOG: checkpoint complete: wrote 128165 buffers > (48.9%); 0 transaction log file(s) added, 0 removed, 64 recycled; > write=55.061 s, sync=0.087 s, total=55.188 s > > 2011-05-17 19:05:53 NOVST LOG: checkpoint starting: xlog > > 2011-05-17 19:06:51 NOVST LOG: checkpoint complete: wrote 138508 buffers > (52.8%); 0 transaction log file(s) added, 0 removed, 64 recycled; > write=57.919 s, sync=0.106 s, total=58.068 s > > 2011-05-17 19:07:08 NOVST LOG: checkpoint starting: xlog > > 2011-05-17 19:08:21 NOVST LOG: checkpoint complete: wrote 132485 buffers > (50.5%); 0 transaction log file(s) added, 0 removed, 64 recycled; > write=72.949 s, sync=0.081 s, total=73.047 s > > 2011-05-17 19:08:40 NOVST LOG: checkpoint starting: xlog > > 2011-05-17 19:09:48 NOVST LOG: checkpoint complete: wrote 139542 buffers > (53.2%); 0 transaction log file(s) added, 0 removed, 64 recycled; > write=68.193 s, sync=0.107 s, total=68.319 s > > 2011-05-17 19:10:06 NOVST LOG: checkpoint starting: xlog > > 2011-05-17 19:11:31 NOVST LOG: checkpoint complete: wrote 137657 buffers > (52.5%); 0 transaction log file(s) added, 0 removed, 64 recycled; > write=84.575 s, sync=0.047 s, total=84.640 s > > > Also I observed more heavy IO from iostat utility. > > > So my questions are: > > 1. How does database size affect insert performance? > > 2. Why does number of written buffers increase when database size grows? > > 3. How can I further analyze this problem? > > -- > Best regards. > --001636ed71a27da3b404a3fece81 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable As near as I can tell from your test configuration description, you have JM= eter --> J2EE --> Postgres.
Have you ruled out the J2EE server as= the problem? This problem may not be the database.
I would take = a look at your app server's health and look for any potential issues th= ere before spending too much time on the database. Perhaps there are memory= issues or excessive garbage collection on the app server?

Terry


On T= ue, May 17, 2011 at 5:45 AM, Andrey Vorobiev <andrey.o.vorobiev@gmail.com>= wrote:

Hi, guys.


I have following environment configuration

- Postgres 8.4.7 with following postresql.conf settings modified:

=A0 =A0 =A0 listen_addresses =3D '*'=A0

=A0 =A0 =A0 max_connections =3D 100


=A0 =A0 =A0 shared_buffers =3D 2048MB=A0

=A0 =A0 =A0 max_prepared_transactions =3D 100

=A0 =A0 =A0 wal_buffers =3D 1024kB


=A0 =A0 =A0 checkpoint_segments =3D 64

=A0 =A0 =A0 checkpoint_completion_target =3D 0.8


=A0 =A0 =A0 log_checkpoints =3D on


- Two databases. Let's call them db_1 and db_2

- J2EE application server that performs inserts into databases defined a= bove. (distribution transactions are used).

- All constraints and indexes are on.

- JMeter that acts as HTTP client and sends requests to server causing i= t to insert rows. (case of new users registration)


After running scenario scenario described above (with 10 concurrent thre= ads) I have observed following behavior:


For the first time everything is fine and J2EE server handles about 700 = requests/sec (about 2500 inserts into several tables per second). But after= some amount of time I observe performance degradation. In general it looks= like the following:


Total number of requests passed; Requests per second;

382000; =A0 768;

546000; =A0 765;

580000; =A0 723;

650000; =A0 700;

671000; =A0 656;

700000; =A0 628;


Checkpoint logging gives me the following:

2011-05-17 18:55:51 NOVST LOG:=A0 checkpoint starting: xlog

2011-05-17 18:57:20 NOVST LOG:=A0 checkpoint complete: wrote 62861 buffe= rs (24.0%); 0 transaction log file(s) added, 0 removed, 0 recycled; write= =3D89.196 s, sync=3D0.029 s, total=3D89.242 s

2011-05-17 18:57:47 NOVST LOG:=A0 checkpoint starting: xlog

2011-05-17 18:59:02 NOVST LOG:=A0 checkpoint complete: wrote 83747 buffe= rs (31.9%); 0 transaction log file(s) added, 0 removed, 64 recycled; write= =3D75.001 s, sync=3D0.043 s, total=3D75.061 s

2011-05-17 18:59:29 NOVST LOG:=A0 checkpoint starting: xlog

2011-05-17 19:00:30 NOVST LOG:=A0 checkpoint complete: wrote 97341 buffe= rs (37.1%); 0 transaction log file(s) added, 0 removed, 64 recycled; write= =3D60.413 s, sync=3D0.050 s, total=3D60.479 s

2011-05-17 19:00:55 NOVST LOG:=A0 checkpoint starting: xlog

2011-05-17 19:01:48 NOVST LOG:=A0 checkpoint complete: wrote 110149 buff= ers (42.0%); 0 transaction log file(s) added, 0 removed, 64 recycled; write= =3D52.285 s, sync=3D0.072 s, total=3D52.379 s

2011-05-17 19:02:11 NOVST LOG:=A0 checkpoint starting: xlog

2011-05-17 19:02:58 NOVST LOG:=A0 checkpoint complete: wrote 120003 buff= ers (45.8%); 0 transaction log file(s) added, 0 removed, 64 recycled; write= =3D46.766 s, sync=3D0.082 s, total=3D46.864 s

2011-05-17 19:03:20 NOVST LOG:=A0 checkpoint starting: xlog

2011-05-17 19:04:18 NOVST LOG:=A0 checkpoint complete: wrote 122296 buff= ers (46.7%); 0 transaction log file(s) added, 0 removed, 64 recycled; write= =3D57.795 s, sync=3D0.054 s, total=3D57.867 s

2011-05-17 19:04:38 NOVST LOG:=A0 checkpoint starting: xlog

2011-05-17 19:05:34 NOVST LOG:=A0 checkpoint complete: wrote 128165 buff= ers (48.9%); 0 transaction log file(s) added, 0 removed, 64 recycled; write= =3D55.061 s, sync=3D0.087 s, total=3D55.188 s

2011-05-17 19:05:53 NOVST LOG:=A0 checkpoint starting: xlog

2011-05-17 19:06:51 NOVST LOG:=A0 checkpoint complete: wrote 138508 buff= ers (52.8%); 0 transaction log file(s) added, 0 removed, 64 recycled; write= =3D57.919 s, sync=3D0.106 s, total=3D58.068 s

2011-05-17 19:07:08 NOVST LOG:=A0 checkpoint starting: xlog

2011-05-17 19:08:21 NOVST LOG:=A0 checkpoint complete: wrote 132485 buff= ers (50.5%); 0 transaction log file(s) added, 0 removed, 64 recycled; write= =3D72.949 s, sync=3D0.081 s, total=3D73.047 s

2011-05-17 19:08:40 NOVST LOG:=A0 checkpoint starting: xlog

2011-05-17 19:09:48 NOVST LOG:=A0 checkpoint complete: wrote 139542 buff= ers (53.2%); 0 transaction log file(s) added, 0 removed, 64 recycled; write= =3D68.193 s, sync=3D0.107 s, total=3D68.319 s

2011-05-17 19:10:06 NOVST LOG:=A0 checkpoint starting: xlog

2011-05-17 19:11:31 NOVST LOG:=A0 checkpoint complete: wrote 137657 buff= ers (52.5%); 0 transaction log file(s) added, 0 removed, 64 recycled; write= =3D84.575 s, sync=3D0.047 s, total=3D84.640 s


Also I observed more heavy=A0 IO from iostat utility.


So my questions are:

1. How does database size affect insert performance?

2. Why does number of written buffers increase when database size grows?=

3. How can I further analyze this problem?


--
Best regards.

--001636ed71a27da3b404a3fece81--