Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id BDD5F2E002D for ; Sat, 3 May 2008 12:07:17 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 36394-04 for ; Sat, 3 May 2008 12:07:13 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from fk-out-0910.google.com (fk-out-0910.google.com [209.85.128.191]) by developer.postgresql.org (Postfix) with ESMTP id 757602E002E for ; Sat, 3 May 2008 12:07:13 -0300 (ADT) Received: by fk-out-0910.google.com with SMTP id e30so36318fke.3 for ; Sat, 03 May 2008 08:07:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=Auu0d46qVYT+HquMhgqKjstjbrBE6mCsyhWVwsH/RLk=; b=wik5GiB9A+Ff25b3j3GTHjevGlai8MbMhvEZ/7xqXGPstyi0LDQyq700tm9GUYj3RtjnI40qYCxk9ZAZlEUExcieu4xbmlq18k6MEnG8HKrV5GXb9HCrUW//5sif7DBQGhcSOoftxWfosT3vFHoUtk7qzbR+V1237XoPPSYuuwA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=jNGLFHtdD/x0S/zdY1zc3ejLjRPTJw6i4vTbtkBKTCIvbk0CQcs/eIig44utYeOHZ4xmXzeD7lz8Stg4g3mKCx8Us+OR54wRNlxqZyY6WW1HFxLSJo6Dp2pPNJiAoWgB6lT9r3nO/6LcYpaGW/gQ25Sd52VbM1bODrZ5YkQfqQw= Received: by 10.82.146.10 with SMTP id t10mr419954bud.31.1209827231945; Sat, 03 May 2008 08:07:11 -0700 (PDT) Received: by 10.82.145.1 with HTTP; Sat, 3 May 2008 08:07:11 -0700 (PDT) Message-ID: Date: Sat, 3 May 2008 11:07:11 -0400 From: "Merlin Moncure" To: "Alexy Khrabrov" Subject: Re: two memory-consuming postgres processes Cc: "Scott Marlowe" , "Tom Lane" , pgsql-performance@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <27A4D379-2553-496D-A96C-102F2A5E62C2@gmail.com> <21403.1209759217@sss.pgh.pa.us> <72E02D29-848B-467A-AE6B-401568010254@gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/41 X-Sequence-Number: 30009 On Fri, May 2, 2008 at 4:51 PM, Alexy Khrabrov wrote: > > On May 2, 2008, at 1:40 PM, Scott Marlowe wrote: > > > Again, a database protects your data from getting scrambled should the > > program updating it quit halfway through etc... > > > > Right -- but this is a data mining work, I add a derived column to a row, > and it's computed from that very row and a small second table which should > fit in RAM. Full table update of a single field is one of the worst possible operations with PostgreSQL. mysql is better at this because lack of proper transactions and full table locking allow the rows to be (mostly) updated in place. Ideally, you should be leveraging the power of PostgreSQL so that you can avoid the full table update if possible. Maybe if you step back and think about the problem you may be able to come up with a solution that is more efficient. Also, if you must do it this way, (as others suggest), do CREATE TABLE new_table AS SELECT...., then create keys, and drop the old table when done. This is much faster than update. merlin