Forum OpenACS Q&A: Re: db_foreach or db_multirow

Collapse
Posted by Jeff Davis on
you should write the query so that is does not return rows you do not want to display. It does not really matter much which of db_foreach or db_multirow you use (the performance difference between the two is almost certainly dwarfed by the cost of going to the db in the first place).

If you are using postgres you can use the "limit 10" statement to only return 10 rows and in oracle you can use rownum < 10 (rownum is a psuedocolumn in all oracle queries). So the trick is to do the query, sort it, and only return the rows you want to display.