Re: Sub-selects taking way too long..

From: "Alexis Maldonado" <alex(at)ctc-disted(dot)net>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Sub-selects taking way too long..
Date: 2002-04-09 21:17:34
Message-ID: 008101c1e00b$f9a3fae0$14818b0a@ctcd.cc.tx.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

cool.. used the EXISTS and now it does it in 3 seconds instead of 40
minutes..
wow.. heheh

ThanX!! hehe

----- Original Message -----
From: "Alexis Maldonado" <amaldona(at)ctcd(dot)cc(dot)tx(dot)us>
To: <pgsql-general(at)postgresql(dot)org>
Sent: Tuesday, April 09, 2002 4:09 PM
Subject: Re: [GENERAL] Sub-selects taking way too long..

> thanks i'll try that :)
>
> ----- Original Message -----
> From: "Stephan Szabo" <sszabo(at)megazone23(dot)bigpanda(dot)com>
> To: "Alexis Maldonado" <amaldona(at)ctcd(dot)cc(dot)tx(dot)us>
> Cc: <pgsql-general(at)postgresql(dot)org>
> Sent: Tuesday, April 09, 2002 3:56 PM
> Subject: Re: [GENERAL] Sub-selects taking way too long..
>
>
> > On Tue, 9 Apr 2002, Alexis Maldonado wrote:
> >
> > > Ok.. I know its provably something im doing dumb..
> > > but here it goes..
> > >
> > > I have 2 tables that are the same:
> > >
> > > "temp_table" and "table"
> > >
> > > "temp _table" has 7,761 rows and "table" is empty
> > >
> > > the columns for both tables are: ID (primary key sequence), index,
> column1,
> > > column2
> > >
> > > when i run:
> > >
> > > Insert Into table
> > > select index, column1, column2
> > > from temp_table
> > > where index NOT IN (select index from table)
> >
> > IN is unfortunately implemented slowly (I think the FAQ answer has more
> > details)
> >
> > You can often get better performance using exists, I think the
equivalent
> > would be:
> > insert into table
> > select index, column1, column2 from temp_table
> > where NOT EXISTS (select * from table where
table.index=temp_Table.index)
> >
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 6: Have you searched our list archives?
> >
> > http://archives.postgresql.org
> >
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2002-04-09 23:44:38 Re: more about pg_toast growth
Previous Message Alexis Maldonado 2002-04-09 21:09:27 Re: Sub-selects taking way too long..