Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id E4C402E0288 for ; Mon, 10 Mar 2008 02:10:25 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 14836-01 for ; Mon, 10 Mar 2008 02:10:21 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from westnet.com (westnet.com [216.187.52.2]) by postgresql.org (Postfix) with ESMTP id D8D112E023E for ; Mon, 10 Mar 2008 02:10:22 -0300 (ADT) Received: from westnet.com (localhost [127.0.0.1]) by westnet.com (8.14.0/8.14.0) with ESMTP id m2A5ALBs004787; Mon, 10 Mar 2008 01:10:21 -0400 (EDT) Received: from localhost (gsmith@localhost) by westnet.com (8.14.0/8.13.2/Submit) with ESMTP id m2A5ALiC004783; Mon, 10 Mar 2008 01:10:21 -0400 (EDT) X-Authentication-Warning: westnet.com: gsmith owned process doing -bs Date: Mon, 10 Mar 2008 01:10:21 -0400 (EDT) From: Greg Smith X-X-Sender: gsmith@westnet.com To: Miguel Arroz cc: pgsql-performance@postgresql.org Subject: Re: UPDATE 66k rows too slow In-Reply-To: <879F65BD-D1B0-4D15-BAE3-056305B84474@guiamac.com> Message-ID: References: <879F65BD-D1B0-4D15-BAE3-056305B84474@guiamac.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200803/190 X-Sequence-Number: 29144 On Mon, 10 Mar 2008, Miguel Arroz wrote: > My question is, how can I "ask" PgSQL what's happening? How can I avoid > guessing, and be sure of what is causing this slowdown? There are many pieces involved here, and any one or multiple of them could be to blame. Someone may make a guess and get lucky about the cause, but the only generic way to solve this sort of thing is to have a systematic approach that goes through the likely possible causes one by one until you've discovered the source of the problem. Since as you say you're new to this, you've got the double task of learning that outline and then finding out how to run each of the tests. For your particular case, slow updates, I usually follow the following series of tests. I happen to have articles on most of these sitting around because they're common issues: -Confirm disks are working as expected: http://www.westnet.com/~gsmith/content/postgresql/pg-disktesting.htm -Look at differences between fsync commit behavior between the two systems. It's often the case that when servers appear slower than development systems it's because the server is doing fsync properly, while the development one is caching fsync in a way that is unsafe for database use but much faster. http://www.postgresql.org/docs/8.3/static/wal-reliability.html is a brief intro to this while http://www.westnet.com/~gsmith/content/postgresql/TuningPGWAL.htm goes into extreme detail. The test_fsync section there is probably the most useful one for your comparision. -Setup basic buffer memory parameters: http://www.westnet.com/~gsmith/content/postgresql/pg-5minute.htm -VACUUM VERBOSE ANALYZE and make sure that's working properly. This requires actually understanding the output from that command which is "fun" to figure out. A related topic is looking for index bloat which I haven't found a good tutorial on yet. -Investigate whether checkpoints are to blame. Since you're running 8.3 you can just turn on log_checkpoints and see how often they're showing up and get an idea how big the performance impact is. Increasing checkpoint_segments is the usual first thing to do if this is the case. -Collect data with vmstat, iostat, and top to figure out what's happening during the problem query -Look for application problems (not your issue here) -- * Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD