Tom Lane wrote:
>> I need the lovely index scan, but my table is hidden behind a view, and
>> all I get is the ugly sequential scan. Any ideas on how to convince the
>> optimizer to unfold the subquery properly?
>
> You should provide some context in this sort of gripe, like which PG
> version yo
Why should these queries have different plans?
create table foo (a int PRIMARY KEY);
Q1: explain select max(a) from foo
> Result (cost=0.04..0.05 rows=1 width=0)
> InitPlan
>-> Limit (cost=0.00..0.04 rows=1 width=4)
> -> Index Scan Backward using foo_pkey on foo
> (cost=0.00