Re: [GENERAL] Fast join

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: Leon <leon(at)udmnet(dot)ru>
Cc: "'pgsql-general(at)hub(dot)org'" <pgsql-general(at)hub(dot)org>
Subject: Re: [GENERAL] Fast join
Date: 1999-06-29 16:50:28
Message-ID: 199906291650.MAA05952@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> But look here:
> -------------
> adb=> EXPLAIN SELECT * FROM atable WHERE atable.cfield = btable.cfield AND
> atable.afield IN (SELECT btable.bfield WHERE btable.bfield=10);
> NOTICE: QUERY PLAN:
>
> Hash Join (cost=1483.00 rows=10000 width=24)
> -> Seq Scan on atable (cost=399.00 rows=10000 width=20)
> SubPlan
> -> Index Scan using gindex on btable (cost=2.05 rows=1 width=4)
> -> Hash (cost=399.00 rows=10000 width=4)
> -> Seq Scan on btable (cost=399.00 rows=10000 width=4)
> -------------

You can't use in index here because an IN is not selective, or if it is,
there is way for the optimizer to know this.

--
Bruce Momjian | http://www.op.net/~candle
maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message ralli 1999-06-29 17:14:09 (no subject)
Previous Message Leon 1999-06-29 16:39:43 Re: [GENERAL] Fast join