Is there any Faster workaround ??

Поиск
Список
Период
Сортировка
Искать

Is there any Faster workaround ??

От:
Rajesh Kumar Mallah <mallah@trade-india.com>
Дата:
Hi folks,

We require to do below or similar quite often

DELETE  from t_a where email in (select email from t_b);

everyone knows "IN" is pain fully slow currently in pgsql
is the any fster alternative to above query

regds
Mallah.


Re: Is there any Faster workaround ??

От:
David Stanaway <david@stanaway.net>
Дата:
On Tue, 2002-04-09 at 14:54, Rajesh Kumar Mallah wrote:
> Hi folks,
> 
> We require to do below or similar quite often
> 
> DELETE  from t_a where email in (select email from t_b);
> 
> everyone knows "IN" is pain fully slow currently in pgsql
> is the any fster alternative to above query
> 

DELETE  from t_a where exists (select email from t_b where t_b.email =
t_a.email);


--
David Stanaway

Re: Is there any Faster workaround ??

От:
Jean-Luc Lachance <jllachan@nsd.ca>
Дата:
How about:

DELETE  from t_a where exist (select email from t_b where t_b.email =
t_a.email)

Rajesh Kumar Mallah wrote:
> 
> Hi folks,
> 
> We require to do below or similar quite often
> 
> DELETE  from t_a where email in (select email from t_b);
> 
> everyone knows "IN" is pain fully slow currently in pgsql
> is the any fster alternative to above query
> 
> regds
> Mallah.
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

Thank you ! Re: Is there any Faster workaround ??

От:
Rajesh Kumar Mallah <mallah@trade-india.com>
Дата:
Thanks so much!

i think this ques. has been answered before also in
this mailing list  sorry for asking...

regds
mallah.

Jean-Luc Lachance wrote:

> How about:
>
> DELETE  from t_a where exist (select email from t_b where t_b.email =
> t_a.email)
>
> Rajesh Kumar Mallah wrote:
> >
> > Hi folks,
> >
> > We require to do below or similar quite often
> >
> > DELETE  from t_a where email in (select email from t_b);
> >
> > everyone knows "IN" is pain fully slow currently in pgsql
> > is the any fster alternative to above query
> >
> > regds
> > Mallah.
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster


new problem! Is there any Faster workaround ??

От:
Rajesh Kumar Mallah <mallah@trade-india.com>
Дата:
 Hi folks, 

I think there is still  a problem ,

email_bank contains  ~ 1  million  records  and t_a contains 58 records
both are indexed on email_id ( integer colmn.)  i want to remove these 58 records
from email_bank  where email_id  in t_a  &  email_bank match.

but the below is still slow !
 

explain delete from email_bank where exists (select email_id from t_a where email_bank.email_id=t_a.email_id) ;
NOTICE:  QUERY PLAN:

Seq Scan on email_bank  (cost=0.00..1760313.80 rows=1009397 width=6)
  SubPlan
    ->  Seq Scan on t_a  (cost=0.00..1.73 rows=1 width=4)

EXPLAIN

PS:
I ran  VACUUM ANALYZE on email_bank and t_a and  both are indexed on email_id  before
the explain .
 

regds
mallah.
 

Rajesh Kumar Mallah wrote:

Hi folks,

We require to do below or similar quite often

DELETE  from t_a where email in (select email from t_b);

everyone knows "IN" is pain fully slow currently in pgsql
is the any fster alternative to above query

regds
Mallah.

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

Re: new problem! Is there any Faster workaround ??

От:
Jeff Eckermann <jeff_eckermann@yahoo.com>
Дата:
A join probably will work best for you.  A quick way
to do an implicit join:

delete from email_bank where email_id = t_a.email_id;

--- Rajesh Kumar Mallah 
wrote:
> Hi folks,
> 
> I think there is still  a problem ,
> 
> email_bank contains  ~ 1  million  records  and t_a
> contains 58 records
> both are indexed on email_id ( integer colmn.)  i
> want to remove these 58
> records
> from email_bank  where email_id  in t_a  & 
> email_bank match.
> 
> but the below is still slow !
> 
> 
> explain delete from email_bank where exists (select
> email_id from t_a where
> email_bank.email_id=t_a.email_id) ;
> NOTICE:  QUERY PLAN:
> 
> Seq Scan on email_bank  (cost=0.00..1760313.80
> rows=1009397 width=6)
>   SubPlan
>     ->  Seq Scan on t_a  (cost=0.00..1.73 rows=1
> width=4)
> 
> EXPLAIN
> 
> PS:
> I ran  VACUUM ANALYZE on email_bank and t_a and 
> both are indexed on
> email_id  before
> the explain .
> 
> 
> regds
> mallah.
> 
> 
> Rajesh Kumar Mallah wrote:
> 
> > Hi folks,
> >
> > We require to do below or similar quite often
> >
> > DELETE  from t_a where email in (select email from
> t_b);
> >
> > everyone knows "IN" is pain fully slow currently
> in pgsql
> > is the any fster alternative to above query
> >
> > regds
> > Mallah.
> >
> > ---------------------------(end of
> broadcast)---------------------------
> > TIP 1: subscribe and unsubscribe commands go to
> majordomo@postgresql.org
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/

Re: new problem! Is there any Faster workaround ??

От:
Rajesh Kumar Mallah <mallah@trade-india.com>
Дата:
Thanks Jeff .

i was not aware of this syntax , i will try it
next time  when i require to do something like this.

unfortunately i have deleted this time
using perl dbi


mallah.

Jeff Eckermann wrote:

> A join probably will work best for you.  A quick way
> to do an implicit join:
>
> delete from email_bank where email_id = t_a.email_id;
>
> --- Rajesh Kumar Mallah 
> wrote:
> > Hi folks,
> >
> > I think there is still  a problem ,
> >
> > email_bank contains  ~ 1  million  records  and t_a
> > contains 58 records
> > both are indexed on email_id ( integer colmn.)  i
> > want to remove these 58
> > records
> > from email_bank  where email_id  in t_a  &
> > email_bank match.
> >
> > but the below is still slow !
> >
> >
> > explain delete from email_bank where exists (select
> > email_id from t_a where
> > email_bank.email_id=t_a.email_id) ;
> > NOTICE:  QUERY PLAN:
> >
> > Seq Scan on email_bank  (cost=0.00..1760313.80
> > rows=1009397 width=6)
> >   SubPlan
> >     ->  Seq Scan on t_a  (cost=0.00..1.73 rows=1
> > width=4)
> >
> > EXPLAIN
> >
> > PS:
> > I ran  VACUUM ANALYZE on email_bank and t_a and
> > both are indexed on
> > email_id  before
> > the explain .
> >
> >
> > regds
> > mallah.
> >
> >
> > Rajesh Kumar Mallah wrote:
> >
> > > Hi folks,
> > >
> > > We require to do below or similar quite often
> > >
> > > DELETE  from t_a where email in (select email from
> > t_b);
> > >
> > > everyone knows "IN" is pain fully slow currently
> > in pgsql
> > > is the any fster alternative to above query
> > >
> > > regds
> > > Mallah.
> > >
> > > ---------------------------(end of
> > broadcast)---------------------------
> > > TIP 1: subscribe and unsubscribe commands go to
> > majordomo@postgresql.org
> >


Optimizer for IN (..) ? / Re: Thank you ! Re: Is there any Faster workaround ??

От:
Bernd von den Brincken <bvdb@asa.de>
Дата:
Hello,

At 09.04.2002 23:32, Rajesh Kumar Mallah  wrote:
>i think this question has been answered before also in
>this mailing list  sorry for asking...
>...
> > How about:
> >
> > DELETE  from t_a where exist (select email from t_b where t_b.email =
> > t_a.email)
> >
> > Rajesh Kumar Mallah wrote:
> > > ... We require to do below or similar quite often
> > >
> > > DELETE  from t_a where email in (select email from t_b);
> > >
> > > everyone knows "IN" is pain fully slow currently in pgsql
> > > is the any fster alternative to above query

Yes this question was posted before - and if so, and if the answer is so 
simple - would it not make sense to implement this wisdom in the optimizer?
Regards
// Bernd vdB


Re: Thank you ! Re: Is there any Faster workaround ??

От:
Roberto Mello <rmello@cc.usu.edu>
Дата:
On Wed, Apr 10, 2002 at 12:24:26PM +0200, Bernd von den Brincken wrote:

> >> > everyone knows "IN" is pain fully slow currently in pgsql
> >> > is the any fster alternative to above query
> 
> Yes this question was posted before - and if so, and if the answer is so 
> simple - would it not make sense to implement this wisdom in the optimizer?

The IN construct is slow in Oracle and probably other RDBMSs too. I don't
know if the PostgreSQL implementation is any slower than others (I don't
think it is).

-Roberto
-- 
+----| http://fslc.usu.edu/ USU Free Software & GNU/Linux Club |------+ Roberto Mello - Computer Science, USU - http://www.brasileiro.net/       http://www.sdl.usu.edu/ - Space Dynamics Lab, Developer    
The more things change, the more they stay the same.

FAQ