static void Nathan_Join(Args _args)
{
System.DateTime first, second;
System.TimeSpan ts;
str dummy;
LedgerTrans lTr;
LedgerTable lTa;
AmountMST amount;
str message;
;
flush LedgerTable;
flush LedgerTrans;
first = System.DateTime::get_Now();
while select AccountNum from lTa where lTa.AccountName like 'Bank*'
{
while select lTr
where lTr.accountNum == lTa.accountNum
{
amount += lTr.amountMST;
}
}
second = System.DateTime::get_Now();
ts = second.Subtract(first);
message += ts.ToString();
message += strFmt("\nNo join: %1\n", amount);
amount = 0;
flush LedgerTable;
flush LedgerTrans;
first = System.DateTime::get_Now();
while select accountNum from lTa where lTa.AccountName like 'Bank*'
join amountMST from lTr
where lTr.accountNum == lTa.accountNum
{
amount += lTr.amountMST;
}
second = System.DateTime::get_Now();
ts = second.Subtract(first);
message += ts.ToString();
message += strFmt("\nJoin amount: %1", amount);
info(message);
}
Result:
00:00:02.5510000
No join: 36,289,571.52
00:00:02.1480000
Join amount: 36,289,571.52
Less that 100% of difference. Smaller scale of difference than the field list and aggregation testing. As mentioned, different data sets would produce different results. If performance matters, it's always worth profiling alternatives - and checking the result is consistent between all alternatives :-)
Note, I've rejigged the output approach so a single infolog message it produced. This is easier to copy/paste into here!
No comments:
Post a Comment