X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 58B959F9CEE for ; Tue, 16 May 2006 21:23:25 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 06659-09 for ; Tue, 16 May 2006 21:23:15 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from server.nextgap2000.com (server.nextgap2000.com [66.98.160.7]) by postgresql.org (Postfix) with ESMTP id 5C4BD9F9C18 for ; Tue, 16 May 2006 21:23:14 -0300 (ADT) Received: from [82.166.55.109] (helo=jonathanlaptop) by server.nextgap2000.com with esmtpa (Exim 4.52) id 1Fg9oj-0004EN-EN for pgsql-performance@postgresql.org; Wed, 17 May 2006 03:23:10 +0300 From: "Jonathan Blitz" To: Subject: Adding and filling new column on big table Date: Wed, 17 May 2006 03:19:26 +0200 Message-ID: <01b401c6794f$f27355e0$ddf71005@jonathanlaptop> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_01B5_01C67960.B5FC25E0" X-Mailer: Microsoft Office Outlook 11 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 thread-index: AcZ5T++5mWZOGFRKQDOtEizQgfW9DA== X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server.nextgap2000.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - anykey.co.il X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/351 X-Sequence-Number: 19138 This is a multi-part message in MIME format. ------=_NextPart_000_01B5_01C67960.B5FC25E0 Content-Type: text/plain; charset="windows-1250" Content-Transfer-Encoding: quoted-printable I have a table of about 500,000 rows.=20 =20 I need to add a new column and populate it. =20 So, I have tried to run the following command. The command never = finishes (I gave up after about and hour and a half!). Note that none of the columns have indexes. =20 Update mytable set new_column =3D =20 case when column_1 =3D column_2 then 1 =20 when column_1+column_3=3D column_2 and column_3 > 0 then 2 =20 when column_1+column_3+column_4 =3D column_2 and column_4 > 0 then 3 =20 when column_1+column_3+column_4+column_5 =3D column_2 and column_5 > 0 then 4 =20 else 0=20 end =20 =20 My computer is a Pentium 4 =96 2.4 GHZ and 1G RAM =96 so it should be = fast enough. =20 Any ideas? =20 Jonathan Blitz =20 --=20 No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.392 / Virus Database: 268.5.6/340 - Release Date: = 05/15/2006 =20 ------=_NextPart_000_01B5_01C67960.B5FC25E0 Content-Type: text/html; charset="windows-1250" Content-Transfer-Encoding: quoted-printable

I have a table of about 500,000 rows. =

 

I need to add a new column and populate = it.

 

So, I have tried to run the following command. The = command never finishes (I gave up after about and hour and a = half!).

Note that none of the columns have = indexes.

 

Update mytable set new_column =3D    =

case when column_1 =3D column_2 =            =             =             =             =             =             then 1  

when column_1+column_3=3D column_2 and column_3 > = 0  =             =             =             then 2  

when column_1+column_3+column_4 =3D column_2 and = column_4 > 0         =             then = 3  

when column_1+column_3+column_4+column_5 =3D column_2 = and column_5 > 0     then 4   =

else =             &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;            = ;            =             &= nbsp;           &n= bsp;           &nb= sp;          0

end

 

 

My computer is a Pentium 4 – 2.4 GHZ and 1G RAM = – so it should be fast enough.

 

Any ideas?

 

Jonathan Blitz

 


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.392 / Virus Database: 268.5.6/340 - Release Date: = 05/15/2006

------=_NextPart_000_01B5_01C67960.B5FC25E0--