On arriving on a form I want to find the current index for a record (not necessarily the current record) with a particular ID. Since the record count is usually no more than 50 I’ve been doing this via looping, comparing the current record with the target. However performance is very bad.
I am reliably told it’s because I’m using the getMaxRecordIndex() command just ahead of the loop. Is there a technique for identifying the target record’s current index without looping?
Not performance tested but I think I may have found a solution to my own problem.
var size = foundset.getSize();
for ( var i = 1 ; i <= size; i++ )
{
var record = foundset.getRecord(i);
if ( globals.gcrid == record.crid )
{
break;
}
}
controller.setSelectedIndex(i);
david:
So “foundset.getSize()” is faster than “getMaxRecordIndex()”? Interesting.
You yourself pointed out by phone how expensive getMaxRecordIndex can be in terms of performance. Switching to foundset.getSize() has indeed cut times dramatically.
In many cases the two commands produce identical results.
I’m not sure but I suspect getMaxRecordIndex() attempts to load all possible records to perform its calculation, while foundset.getSize() just returns the record count of the current set, all that’s really wanted most of the time. I’m gropping around for an explanation of the two architectures, but something along those lines is probably at work.
There are circumstances in which I want to process ALL available records, to keep loading, not just process the current set. Am I correct in assuming only the following will do that?
it will loop through your foundset, NOT all records in your table
example
assume you’ve done a search with result of 1000 records (5000 rec total in table)
var counter = foundset.getSize()
// counter will have value of about 200 (currently present in memory)
so next loop will only go through part of your foundset