Re: [HACKERS] Strange query plan with redundant aggregate nodes

2009-04-09 Thread Tom Lane
Gregory Stark writes: > I don't really understand what's going on here. It's flattening the sub-select, converting select sum(n),sum(n) from (select (select count(*) as n from a ) as n from (select random() as s) as xyzzy) as xyzzy ; to select sum((select count(*) from a)), su

[HACKERS] Strange query plan with redundant aggregate nodes

2009-04-09 Thread Gregory Stark
This query surprised me. I expected us to do the Aggregate once for all the aggregate functions in the select target which is what normally happens. If I simplify the query further it actually does so. I don't really understand what's going on here. It can't be the volatile random() because in f

Re: [HACKERS] Strange query plan

2001-06-05 Thread Tom Lane
Oleg Bartunov <[EMAIL PROTECTED]> writes: > select msg_prt.tid as mid from msg_prt > where exists (select idx.tid from idx where msg_prt.tid=idx.tid > and idx.did=1 and idx.lid in (1207,59587) ) > NOTICE: QUERY PLAN: > Seq Scan on msg_prt (cost=0.00..119090807.13 rows=69505 wid