On 4/8/06, Tom Lane <[EMAIL PROTECTED]> wrote: > A function implemented as per Michael's example would not give the > results that I think people would expect for > > SELECT rownum(), * FROM foo ORDER BY whatever; >
Yep, the query would have to be rewritten similar to Oracle's: SELECT rownum(), * FROM (SELECT * FROM foo ORDER BY whatever); IIRC, processing-wise, rownum and order-by processing is handled as follows: SELECT id, whatever FROM foo WHERE rownum <= 10 ORDER BY id; is the same as PostgreSQL's SELECT id, whatever FROM (SELECT id, whatever FROM foo LIMIT 10) ORDER BY id; -- Jonah H. Harris, Database Internals Architect EnterpriseDB Corporation 732.331.1324 ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match