| From: | Oleg Samoylov <olleg(at)telecom(dot)mipt(dot)ru> |
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: Insert multiple Rows |
| Date: | 2003-03-04 10:54:40 |
| Message-ID: | b420lg$1um4$1@news.hub.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
Hi,
Saint X wrote:
> Hi, I have a program that need to send a Postgresql database a lot of
> rows, i'm doing it using FOR an INSERT, something like this
> for i = 0 to 1000
> {
> insert into table(item1) VALUES (i);
> }
>
> And so on, as you can imagine these consume a lot of resources and
> move so slowly, that's why I'm looking for a command to send more than
> one row at the time, something like
>
> insert into table (item1) values ('1' / '2' / '3' / '4' ... / '1000');
You can do instead:
insert into table (item1) values ('1');
insert into table (item1) values ('2');
....
insert into table (item1) values ('1000');
As single query.
But better use COPY command or prepared statment.
Inserts slow commonly due to indexis and foreing keys.
--
Olleg Samoylov
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Christoph Haller | 2003-03-04 11:14:18 | Re: using Avg() |
| Previous Message | Richard Huxton | 2003-03-04 09:20:52 | Re: Checking my HD space (noarchive) |