Thursday, July 1, 2010

Aggregation comparison

We perform a while/select and compare that to using an aggregation function, count():

static void Nathan_Aggregation(Args _args)
{
CustTable ct;
System.DateTime first, second;
System.TimeSpan ts;
int counter;
;

flush CustTable;
first = System.DateTime::get_Now();
while select * from ct
{
counter++;
}
second = System.DateTime::get_Now();
ts = second.Subtract(first);
info(ts.ToString());
info(strFmt("Count of CustTable records using while-select: %1", counter));

flush CustTable;
first = System.DateTime::get_Now();
select count(RecId) from ct;
second = System.DateTime::get_Now();
ts = second.Subtract(first);
info(ts.ToString());
info(strFmt("Count of CustTable records using count() aggregate function: %1", ct.RecId));
}


Output:
00:00:27.1730000
Count of CustTable records using while-select: 41904
00:00:00.6350000
Count of CustTable records using count() aggregate function: 41904

Performance improvement factor: 42.8

No comments:

Post a Comment