pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ezequias R. da Rocha <ezequias@fastcon.com.br>
To: Ezequias R. da Rocha <ezequias@fastcon.com.br>
To: pgsql-sql@postgresql.org
Subject: Re: For loop
Date: Tue, 13 Mar 2007 11:32:35 -0300
Message-ID: <45F6B603.2050207@fastcon.com.br> (raw)
In-Reply-To: <20070313142744.GA7548@alvh.no-ip.org>
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>

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.
>
>   




view thread (16+ messages)

Message-ID: <45F6B603.2050207@fastcon.com.br>
Permalink:  ../45F6B603.2050207@fastcon.com.br/
Also on:    postgresql.org/message-id/45F6B603.2050207@fastcon.com.br

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ezequias@fastcon.com.br
  Subject: Re: For loop
  In-Reply-To: <45F6B603.2050207@fastcon.com.br>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox