Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 9E6269FB8A1 for ; Tue, 13 Mar 2007 11:35:03 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 00285-01 for ; Tue, 13 Mar 2007 11:34:49 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from correio2.docasdoporto.com.br (8.144.199.200.docasdoporto.com.br [200.199.144.8]) by postgresql.org (Postfix) with ESMTP id 068469FB89D for ; Tue, 13 Mar 2007 11:34:54 -0300 (ADT) Received: from [201.30.172.2] (account ezequias@fastcon.com.br HELO [192.168.0.110]) by correio2.docasdoporto.com.br (CommuniGate Pro SMTP 4.1.8) with ESMTP id 46365156; Tue, 13 Mar 2007 11:51:54 -0300 Message-ID: <45F6B603.2050207@fastcon.com.br> Date: Tue, 13 Mar 2007 11:32:35 -0300 From: "Ezequias R. da Rocha" User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 To: "Ezequias R. da Rocha" , pgsql-sql@postgresql.org Subject: Re: For loop References: <45F69D7C.4070304@fastcon.com.br> <45F6B4EB.A3DD.0030.0@indicator.be> <45F6A793.1090904@fastcon.com.br> <200703130644.20870.aklaver@comcast.net> <45F6AF3B.4080706@fastcon.com.br> <20070313142744.GA7548@alvh.no-ip.org> In-Reply-To: <20070313142744.GA7548@alvh.no-ip.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/168 X-Sequence-Number: 27806 I rewritte the Jonah's function to: FOR iter IN 1 .. num_iter LOOP -- some computations INSERT INTO carga (descricao) VALUES ('CardPass'); END LOOP; My ID is now() by default And it was in 23sec After I changed the insert to: INSERT INTO carga (id,descricao) VALUES ('2007-03-13 10:20:20','CardPass'); And it was in: 19485ms Great don't you ? Ezequias Alvaro Herrera escreveu: > Ezequias R. da Rocha wrote: > >> Thank you all. The function from Jonah solves my problem. >> >> Just a simple question: >> >> One million of inserctions in *28,8* seconds with this kind of data >> (timestamp|character varring (50)) is a good performance ? >> >> I let my questions to DBAs from PostgreSQL. >> > > I don't know, but Jonah's function can be better written using pure SQL, > which should be faster. Something like this: > > create table whatever (a text, b int); > insert into whatever > select 'My text from iteration ' || a, a * 2 > from generate_series(1, 1000000) a; > > I don't claim this works as is, but you should get the hang of it. > >