Re: [GENERAL] Window functions can't be used as LIMIT/FETCH FIRST alternative

2017-05-20 Thread David G. Johnston
On Sat, May 20, 2017 at 2:50 AM, Navrotskiy Artem wrote: > This is especially unpleasant for expressions using RANK and DENSE_RANK, > which can not simply be rewritten using LIMIT. > ​They cannot anyway, at least not DENSE_RANK with ties.​ Others will have to speak to the dynamics involved with

[GENERAL] Window functions can't be used as LIMIT/FETCH FIRST alternative

2017-05-20 Thread Navrotskiy Artem
Hello. I found unexpected query optimization issue: window functions can't be used as LIMIT/FETCH FIRST alternative (as far as I know, before SQL:2008 it was the only standard way to implement LIMIT in the query). The problem is that PostgreSQL does not stop reading the records after reaching the l