Created
October 11, 2015 05:58
-
-
Save mountaindude/c86f9ea1a0062a1d3cea to your computer and use it in GitHub Desktop.
Fastest way of finding max/min values of a field in Sense or QV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The obvious way of finding the max/min value of a field might something like this: | |
// | |
// LOAD max(salesDate) Resident dataTable; | |
// | |
// However, if dataTable is very large (hundred of millions of lines or more, with many columns), the above will be | |
// very slow, as we will end up traversing that entire table. | |
// | |
// Instead, the fastest method of achieving the desired result is to load the FieldValue()s. | |
// We then only look at the values of the salesDate field itself, and not the entire dataTable table. | |
// Performance gains by many orders of magnitude can be gained by using this method. | |
// | |
LOAD max(FieldValue('salesDate', recno())) | |
AUTOGENERATE FieldValueCount('salesDate'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment