Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 4C624B5DBBE for ; Sun, 10 Jul 2011 17:34:42 -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 72499-01 for ; Sun, 10 Jul 2011 20:34:36 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from nm10-vm0.bullet.mail.ne1.yahoo.com (nm10-vm0.bullet.mail.ne1.yahoo.com [98.138.91.72]) by mail.postgresql.org (Postfix) with SMTP id B03E3B5D803 for ; Sun, 10 Jul 2011 17:34:35 -0300 (ADT) Received: from [98.138.90.57] by nm10.bullet.mail.ne1.yahoo.com with NNFMP; 10 Jul 2011 20:34:33 -0000 Received: from [98.138.226.56] by tm10.bullet.mail.ne1.yahoo.com with NNFMP; 10 Jul 2011 20:34:33 -0000 Received: from [127.0.0.1] by smtp207.mail.ne1.yahoo.com with NNFMP; 10 Jul 2011 20:34:33 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1310330073; bh=Mv5jq4oBIHBJ3U9a9rpK4Q67ojdmBcvhz7xO530gdcQ=; h=X-Yahoo-Newman-Id:Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=frLQVPkWL46E0i6AvJXNAYhlCBQjf8o4iYasfVwKE31Cn3kTvkibNPo7zfac616GedJasv6p7oXx1rhgMH0i5c5aAKTrVYeZlPwGwzjVL4u18AjaFrbgeoLfCYpOE1km7rau9SHVEIulQh9DS5PmvbjQt2dywHiVqGj4Ef4DQOE= X-Yahoo-Newman-Id: 592920.48623.bm@smtp207.mail.ne1.yahoo.com Received: from [192.168.206.5] (lhofhansl@67.170.234.149 with plain) by smtp207.mail.ne1.yahoo.com with SMTP; 10 Jul 2011 13:34:33 -0700 PDT X-Yahoo-SMTP: YmezqLWswBDx0ai534H100MJuqGzDQ-- X-YMail-OSG: O2NWyrQVM1kO3EoWhXZfMlRgPIhHRzscFllkucaZyvsEq7b KsJ.MQLNHD_p9bggBTWp43o1u6AryYPUVU8s6IPSiOlPKrwQiV81f..SpFFx ITnt6BeJXWXDEmnCPxpZ3T1SVUhSaDsKmPST7t7_5It4lFQisVG_NmnN7c4l Yxw1qm8hJpGaMOMiGr7Ad3qdcuVqzqsEQORbm9vKJd8iQZzXibg5sK3MNhrK nDpvPAAL4CVQJUSFh83PbNL0wA6o0t6LuqVHiI.4GwTFmL7lMNxVlaD0ybE_ qgXtMsENoZRzCv0thLLU.2eZ5jW7DWcM0GCMkCfTqASHGMrzccFgR2ubsJn. yBUwhopXpz6i.RhCE9.7bEw-- X-Yahoo-Newman-Property: ymail-3 Message-ID: <4E1A0CBC.6090009@yahoo.com> Date: Sun, 10 Jul 2011 13:34:04 -0700 From: lars User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110621 Fedora/3.1.11-1.fc14 Thunderbird/3.1.11 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: UPDATEDs slowing SELECTs in a fully cached database References: <4E16479D.3050605@yahoo.com> In-Reply-To: <4E16479D.3050605@yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, T_RP_MATCHES_RCVD=-0.01, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201107/87 X-Sequence-Number: 44299 I have since moved the WAL to its own EBS volume (ext4, data=writeback) to make it easier to monitor IO. The times where the SELECTs slow down coincide with heavy write traffic to the WAL volume. Maybe this has to do with WALInsertLock or WALWriteLock (or some other lock). Since the slowdown was less severe with WAL on its own volume it seems some exclusive lock on the pages in shared_buffers is held while WAL IO is in progres(?) - that would be "frustrating". (wal_buffers default to 16mb in my setup) Next I am going to have a look at the code. I would be thankful for any further insights, though :) Thanks. -- Lars On 07/07/2011 04:56 PM, lars wrote: > I am doing some research that will hopefully lead to replacing a big > Oracle installation with a set PostgreSQL servers. > > The current Oracle installations consists of multiple of RAC clusters > with 8 RAC nodes each. Each RAC node has 256gb of > memory (to be doubled soon). > The nature of our service is such that over a reasonable time (a day > or so) the database *is* the working set. > > So I am looking at Postgres in a context where (almost) all of the > data is cached and disk IO is only required for persistence. > > Setup: > PostgreSQL 9.1beta2 on a high memory (~68gb, 12 cores) EC2 Linux > instance (kernel 2.6.35) with the database and > WAL residing on the same EBS volume with EXT4 (data=ordered, > barriers=1) - yes that is not an ideal setup > (WAL should be on separate drive, EBS is slow to begin, etc), but I am > mostly interested in read performance for a fully cached database. > > shared_buffers: varied between 1gb and 20gb > checkpoint_segments/timeout: varied accordingly between 16-256 and > 5-10m, resp. > bgwriter tweaked to get a good distribution of checkpoints, bg-writes, > and backend writes. > wal_sync_method: tried fdatasync and open_datasync. > > I read "PostgreSQL 9.0 high performance", and have spent some > significant amount of time on this already. > > PostgreSQL holds up extremely well, once things like "storing > hint-bits", checkpoints vs bgwriter vs backend_writes, etc > are understood. I installed pg_buffercache and pgfincore to monitor > how and where the database is stored. > > There is one observation that I wasn't able to explain: > A SELECT only client is severely slowed down by a concurrent client > performing UPDATES on the same table the other > client selects from, even when the database resides 100% in the cache > (I tried with shared_buffers large enough to hold > the database, and also with a smaller setting relying on the OS cache, > the behavior is the same). > > As long as only the reader is running I get great performance > (20-30ms, query reading a random set of about 10000 rows > out of 100m row table in a single SELECT). The backend is close to > 100% cpu, which is what want in a cached database. > > Once the writer starts the read performance drops almost immediately > to >200ms. > The reading backend's cpu drop drop to <10%, and is mostly waiting (D > state in top). > The UPDATE touches a random set of also about 10000 rows (in one > update statement, one of the columns touched is > indexed - and that is the same index used for the SELECTs). > > What I would have expected is that the SELECTs would just continue to > read from the cached buffers (whether dirtied > or not) and not be affected by concurrent updates. I could not find > anything explaining this. > > The most interesting part: > that this does not happen with an exact clone of that relation but > UNLOGGED. The same amount of buffers get dirty, > the same amount checkpointing, bgwriting, vacuuming. The only > difference is WAL maintenance as far as I can tell. > > Is there some (intentional or not) synchronization between backend > when the WAL is maintained? Are there times when > read only query needs to compete disk IO when everything is cached? Or > are there any other explanations? > > I am happy to provide more information. Although I am mainly looking > for a qualitative answer, which could explain this behavior. > > Thanks. > > -- Lars >