Limit and Offset on Queries

Limit and Offset on Queries



I'm currently working in a project where the client has some web services running on a Postgres DB and wants to mimic the Postgres LIMIT behaviour in our app.

I could do something like:
        SELECT TOP y <fields>
        FROM table
        WHERE <conditions>
        ORDER BY table.field  ASC) as t2
    ORDER by field DESC) as t1
ORDER by field ASC

where x is the number of rows you want returned and y is x+offset.

This extra nesting should add some load to the query, but not much I believe...

Is there a "smarter" way of doing this in OutSystems?

Best regards,

Not sure if there is a smarter way for it.

depending on the real situation and how often it changes.

will give you some suggestions.

(1. use only the inner sql, and do a for-each loop and solve the X on that way (duplicating the list))

2. use only the inner sql, place it in table and set the startindex X and go from there