Re: [PERFORM] limit is sometimes not pushed in view with order

2013-04-14 Thread Rikard Pavelic
On Sat, 13 Apr 2013 20:08:16 +0200 Rikard Pavelic wrote: > While one could argue that optimizer doesn't know to optimize left > join with group by its primary key, you can replace that join with > some other joins (ie left join to another table pk) and the same > behavior will be displayed (joini

Re: [PERFORM] limit is sometimes not pushed in view with order

2013-04-13 Thread Rikard Pavelic
On Sat, 13 Apr 2013 11:21:19 -0400 Tom Lane wrote: > The planner realizes that about 1/200th of the table satisfies the > "ord" condition, so it estimates that the first plan will require > scanning about 2000 entries in the pkey index to get 10 results. So > that looks significantly cheaper tha

Re: [PERFORM] limit is sometimes not pushed in view with order

2013-04-13 Thread Julian
On 13/04/13 18:25, Rikard Pavelic wrote: > I was investigating some performance issues and stumbled upon this behavior: > > create table main_table (i serial primary key, data varchar, ord int); > create view main_view_order as select m.i, m.data, m.ord from main_table m > order by m.i desc; > >

Re: [PERFORM] limit is sometimes not pushed in view with order

2013-04-13 Thread Tom Lane
Rikard Pavelic writes: > I was investigating some performance issues and stumbled upon this behavior: > create table main_table (i serial primary key, data varchar, ord int); > create view main_view_order as select m.i, m.data, m.ord from main_table m > order by m.i desc; > insert into main_tabl