From mallah@trade-india.com Tue Apr 9 21:43:10 2002 Received: from trade-india.com (unknown [130.94.20.28]) by postgresql.org (Postfix) with SMTP id 5EAD8475975 for ; Tue, 9 Apr 2002 17:43:10 -0400 (EDT) Received: (qmail 20805 invoked from network); 9 Apr 2002 21:54:59 -0000 Received: from ptil-235-129-del.primus-india.net (HELO trade-india.com) (203.196.129.235) by 130.94.22.209 with SMTP; 9 Apr 2002 21:54:59 -0000 Message-ID: <3CB3613A.FEE6891E@trade-india.com> Date: Wed, 10 Apr 2002 03:16:34 +0530 From: Rajesh Kumar Mallah X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.4.2-2 i686) X-Accept-Language: en MIME-Version: 1.0 To: PostgResql SQL Mailing List Subject: new problem! Is there any Faster workaround ?? References: <3CB346F6.1DD7CFB9@trade-india.com> Content-Type: multipart/alternative; boundary="------------C0528C9DBDCEFDAA1046E691" X-Archive-Number: 200204/111 X-Sequence-Number: 7376 --------------C0528C9DBDCEFDAA1046E691 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 --------------C0528C9DBDCEFDAA1046E691 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit 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

--------------C0528C9DBDCEFDAA1046E691-- From jeff_eckermann@yahoo.com Wed Apr 10 15:44:13 2002 Received: from web20802.mail.yahoo.com (web20802.mail.yahoo.com [216.136.226.191]) by postgresql.org (Postfix) with SMTP id 7650847640F for ; Wed, 10 Apr 2002 11:44:13 -0400 (EDT) Message-ID: <20020410154416.78018.qmail@web20802.mail.yahoo.com> Received: from [68.14.98.218] by web20802.mail.yahoo.com via HTTP; Wed, 10 Apr 2002 08:44:16 PDT Date: Wed, 10 Apr 2002 08:44:16 -0700 (PDT) From: Jeff Eckermann Subject: Re: new problem! Is there any Faster workaround ?? To: Rajesh Kumar Mallah , PostgResql SQL Mailing List In-Reply-To: <3CB3613A.FEE6891E@trade-india.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200204/117 X-Sequence-Number: 7382 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/ From mallah@trade-india.com Thu Apr 11 06:43:12 2002 Received: from trade-india.com (unknown [130.94.20.28]) by postgresql.org (Postfix) with SMTP id 69C2B4758DA for ; Thu, 11 Apr 2002 02:43:12 -0400 (EDT) Received: (qmail 30419 invoked from network); 11 Apr 2002 06:55:19 -0000 Received: from ptil-235-129-del.primus-india.net (HELO trade-india.com) (203.196.129.235) by 130.94.22.209 with SMTP; 11 Apr 2002 06:55:19 -0000 Message-ID: <3CB53148.666AF356@trade-india.com> Date: Thu, 11 Apr 2002 12:16:32 +0530 From: Rajesh Kumar Mallah X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.4.2-2 i686) X-Accept-Language: en MIME-Version: 1.0 To: Jeff Eckermann Cc: PostgResql SQL Mailing List Subject: Re: new problem! Is there any Faster workaround ?? References: <20020410154416.78018.qmail@web20802.mail.yahoo.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200204/127 X-Sequence-Number: 7392 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 > >