Tech Tip: Using "order by" in query string to reduce server request
PRODUCT: 4D | VERSION: 19 | PLATFORM: Mac & Win
Published On: December 6, 2021
Typically when querying and ordering a dataClass or entity selection, the commands .query() and .orderBy() would be used and treated as 2 separate requests to the server as shown below:
$es:=ds.Table_1.query("ID < 10").orderBy("Field_1") |
However, you can save a request to the server by including the "order by" line within the query string as shown below:
$es:=ds.Table_1.query("ID < 10 order by Field_1") |
Note that the "order by" within the query string are exclusive to dataClass and entitySelections and will not work on collections since collections are typically used locally and do not require any server request.