> -----Original Message-----
> From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
> Sent: Wednesday, July 21, 1999 12:32 AM
> To: Hiroshi Inoue
> Cc: pgsql-hackers
> Subject: Re: [HACKERS] selectivity calculation for or_clause is wrong ?
>
>
> "Hiroshi Inoue" <Inoue@tpf.co.jp> writes:
> > Why is valid_or_clause(clausenode) necessary ?
>
> Looks like a waste of cycles to me too.
>
It's not only a waste of cycles.
For exmaple,
1.explain select key1 from b where someitem in (1);
NOTICE: QUERY PLAN:
Seq Scan on b on b (cost=1638.49 rows=261 width=4)
2.explain select key1 from b where someitem in (1,2);
NOTICE: QUERY PLAN:
Seq Scan on b on b (cost=1638.49 rows=773 width=4)
3.explain select key1 from b where someitem in (1,2,3);
NOTICE: QUERY PLAN:
Seq Scan on b on b (cost=1638.49 rows=1274 width=4)
rows of each plan 261 : 773 : 1274 not = 1 : 2 : 3.
It's nearly = 1 :3 :5.
elements of or_clause except its first element are evaluated
twice and the results are accumlated.
Regards.
Hiroshi Inoue
Inoue@tpf.co.jp