pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dirk Jagdmann <jagdmann@gmail.com>
To: pgsql-sql@postgresql.org
Subject: optimal insert
Date: Sun, 8 Oct 2006 23:04:02 +0200
Message-ID: <5d0f60990610081404s79a90cdbha4603c70c75ce233@mail.gmail.com> (raw)

Hello experts,

I have a database that contains three tables:

create table a (
  id serial primary key,
  ... -- some more fields not relevant for my question
);
create table b (
  id serial primary key,
  ... -- some more fields not relevant for my question
);
create table a_b (
  a int not null references a,
  b int not null references b
);

Tables a and b have already been filled with lots of rows. Now my
application needs to insert the relationship of a to b into table a_b
and is currently doing it with inserts like the following:

insert into a_b(a,b) values(1,100);
insert into a_b(a,b) values(1,200);
insert into a_b(a,b) values(1,54);
insert into a_b(a,b) values(1,4577);

So for a batch of inserts the value of a stays the same, while for by
arbitrary values are inserted. Now I have wondered if PostreSQL offers
a smarter way to insert those values? A solution can contains usage of
some plpgsql code.

-- 
---> Dirk Jagdmann
----> http://cubic.org/~doj
-----> http://llg.cubic.org



view thread (7+ messages)  latest in thread

Message-ID: <5d0f60990610081404s79a90cdbha4603c70c75ce233@mail.gmail.com>
Permalink:  ../5d0f60990610081404s79a90cdbha4603c70c75ce233@mail.gmail.com/
Also on:    postgresql.org/message-id/5d0f60990610081404s79a90cdbha4603c70c75ce233@mail.gmail.com

 · 

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: jagdmann@gmail.com
  Subject: Re: optimal insert
  In-Reply-To: <5d0f60990610081404s79a90cdbha4603c70c75ce233@mail.gmail.com>

* 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