Re: For loop

From: "Ezequias R(dot) da Rocha" <ezequias(at)fastcon(dot)com(dot)br>
To: "Ezequias R(dot) da Rocha" <ezequias(at)fastcon(dot)com(dot)br>, pgsql-sql(at)postgresql(dot)org
Subject: Re: For loop
Date: 2007-03-13 14:32:35
Message-ID: 45F6B603.2050207@fastcon.com.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Ezequias Rodrigues da Rocha 2007-03-13 15:59:12 PgAdmin 1.6.2 crashes when resize the collumn
Previous Message Alvaro Herrera 2007-03-13 14:27:44 Re: For loop