X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A7ACE3A5971 for ; Wed, 26 Jan 2005 00:12:49 +0000 (GMT) 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 41785-01 for ; Wed, 26 Jan 2005 00:12:43 +0000 (GMT) Received: from lucifer.oficina (unknown [200.68.121.201]) by svr1.postgresql.org (Postfix) with ESMTP id AEC8E3A58C2 for ; Wed, 26 Jan 2005 00:12:41 +0000 (GMT) Received: from localhost (localhost.akyasociados.com.ar [127.0.0.1]) by lucifer.oficina (8.13.1/8.12.10) with ESMTP id j0Q0CLwO035589; Tue, 25 Jan 2005 21:12:21 -0300 (ART) (envelope-from franco@akyasociados.com.ar) Received: from lucifer.oficina ([127.0.0.1]) by localhost (lucifer.oficina [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 34396-10; Tue, 25 Jan 2005 21:12:19 -0300 (ART) Received: from [192.168.1.168] (taz.oficina [192.168.1.168]) (authenticated bits=0) by lucifer.oficina (8.13.1/8.12.10) with ESMTP id j0Q0CEi4035586; Tue, 25 Jan 2005 21:12:15 -0300 (ART) (envelope-from franco@akyasociados.com.ar) Message-ID: <41F6E062.2080009@akyasociados.com.ar> Date: Tue, 25 Jan 2005 21:12:18 -0300 From: Franco Bruno Borghesi User-Agent: Mozilla Thunderbird 1.0 (X11/20041216) X-Accept-Language: en-us, en MIME-Version: 1.0 To: mrblonde@locked.myftp.org Cc: pgsql-sql@postgresql.org Subject: Re: update from multiple rows References: <20050124233220.6CA161C00085@mwinf1206.wanadoo.fr> In-Reply-To: <20050124233220.6CA161C00085@mwinf1206.wanadoo.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at akyasociados.com.ar X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.111 tagged_above=0 required=5 tests=AWL, RCVD_IN_SORBS_DUL X-Spam-Level: X-Archive-Number: 200501/240 X-Sequence-Number: 20028 updating 40.000 records should take no longer than a couple of minutes. I think you should optimise your query before going any further. You have an inner SELECT sentence that executes before anything. It joins EVERY row in your table (1,000,000+) with at most 3 other rows in the same table, so you will end up with about 3,000,000+ rows... but you are interested in only 40,000 rows! To make it simple, add a WHERE condition to fetch only the 40.000 rows you are interested in and discard the others. Make sure also you have indexed the attributes you are filtering on, and the date attribute too. You should use EXPLAIN ANALYZE on the inner query to check how it improves. Once your SELECT query runs fast enough, the UPDATE should go much faster too. The number of columns matters, but as I said, I don't think it's an UPDATE problem. If you don't find the way to speed your query up, try posting to the performance list. mrblonde@locked.myftp.org wrote: >Thanks a lot.. That is what i searched.. In fact your query is very good for little changes, but i will have to use another method when updating all my rows because the performance is not very good alas. > >My data set contains something like 40000 rows to update in 1+ million records and data_raw, data_sys are of type "real"... The complete update took 40 minutes on a 256Mo, athlon 2400, kernel 2.6 and with no charge during the execution of the query. > >Is this normal ? The number of columns of the table does it matter a lot (the table contains 12 reals and 4 integers) ? > >I found that using an intermediate table which stock for every row the value before and the value after helps to gain speed... But it is not a very nice way i think.. > >Thanks again :) >Etienne > > >---------------------------(end of broadcast)--------------------------- >TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq > > >