Anyone can commet that issue?
More extremal sample (simplified version of what i get in real world situation):
same table data...
Query:
select * from (SELECT table1.id,(select count(*) from table2 where table2.fk=table1.id) as total from table1) as t1 where total=990 or total=991 or total=992 o
postgresql version 8.3:
I found issue when optimisator had tried rollup subrequest (without attempt
compare final cost with direct plan) and finished with bad plan.
The simplest test is below:
Preparing data:
testdb=# INSERT INTO table2 select (random()*99+1)::integer from
generate_series(1,1