Separating data sets in a table

Поиск
Список
Период
Сортировка
От Andreas Tille
Тема Separating data sets in a table
Дата
Msg-id Pine.LNX.4.44.0208221126490.1478-100000@wr-linux02.rki.ivbb.bund.de
обсуждение исходный текст
Ответы Updatable View (Was: Separating data sets in a table)  (Andreas Tille <tillea@rki.de>)
Re: Separating data sets in a table  (Mark Stosberg <mark@summersault.com>)
Список pgsql-sql
Hello,

I want to solve the following problem:

CREATE TABLE Ref    ( Id int ) ;
CREATE TABLE Import ( Id    int,                     Other varchar(42),                     Flag  int,
  Ts    timestamp ) ;
 
CREATE TABLE Data   ( Id    int,                     Other varchar(42) ) ;

The table Import will be filled by a COPY FROM statement and contains
no checks for referential integrity.  The columns Id and Other have to
be moved to the table Data if the table Ref contains the Id.  If not
Flag should get a certain value that something went wrong.  Moreover
Import should only contain one representation  of a dataset with equal
Id and Other column and I would like to store the newest one (this
is the reason for the timestamp).

I tried to do the following approach:
  CREATE LOCAL TEMPORARY TABLE ImportOK () INHERITS (Import) ;
  INSERT INTO ImportOK SELECT * FROM Import i         INNER JOIN  Ref r ON i.Id = r.Id;
  DELETE FROM Import WHERE Id IN (SELECT Id FROM ImportOK) ;

The idea was that the latest statement should get rid of all valid
data sets from Import.  The valid datasets now could be moved to Data
and I could afterwards check Import for duplicated data sets.
Unfortunately the latest statement is so terribly slow that I can't
imagine that there is a better way to do this.

It seems like a very beginner question but I have no real clue how
to do this right.  Probably the solution has to be done completely
different.

Thanks for your patience
         Andreas.



В списке pgsql-sql по дате отправления:

Предыдущее
От: "Rajesh Kumar Mallah."
Дата:
Сообщение: BITMAP INDEXES...
Следующее
От: Lucas Brasilino
Дата:
Сообщение: Re: Problem with timestamp field/time function.. (upgrading