Precisely Speaking
May 18, 2012, 02:48:37 PM
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
: So what's news with you? Tell us about it in "Getting To Know You"!
Home
Help
Calendar
Login
Register
Precisely Speaking
>
Training and Education
>
U2 Programming Questions
>
Sweating the Small Stuff
Pages: [
1
]
Go Down
« previous
next »
Print
Author
Topic: Sweating the Small Stuff (Read 3764 times)
precisonline
President/Chief Technologist
Administrator
Rock Star
Posts: 1532
Sweating the Small Stuff
«
on:
April 24, 2007, 09:41:05 PM »
A couple of days ago I received a request where someone was writing a SUBR(..) type dictionary that was taking a long time to run in the context of a UniQuery statement. In this subroutine were the following lines:
BIN.CNT = DCOUNT(REC<79>,@VM)
FOR BIN.LOOP = 1 TO BIN.CNT
BIN = REC<79,BIN.LOOP>
...
NEXT BIN.LOOP
I suggested that the extraction from attribute 79 could benefit from some simple optimization, as follows:
BIN.LIST = REC<79>
BIN.CNT = DCOUNT(BIN.LIST,@VM)
FOR BIN.LOOP = 1 TO BIN.CNT
BIN = BIN.LIST<1,BIN.LOOP>
...
NEXT BIN.LOOP
This small change, which many people might find otherwise innocuous, reduced the processing time of this particular routine from ~30 minutes to ~2. If the bin lists were of any size at all (they usually have less than a half dozen entries) I would have also recommended using REMOVE instead of the extraction, but the client was pleased with the progress of the simple optimization so there was no pressing need for the next level.
This just goes to show how the small stuff can make a big difference when you multiply it times a couple hundred thousand records!
Logged
-Kevin
Accidents "happen"; success, however, is planned and executed.
Tom Pellitieri
Rock Star
Posts: 170
Tom Pellitieri - Toledo, Ohio
Re: Sweating the Small Stuff
«
Reply #1 on:
April 25, 2007, 06:38:06 AM »
In UniBasic, you can use List Processing instead of REMOVE to get the same benefits. E.g.:
BINS = RAISE(REC<79>)
SELECT BINS TO BIN.LIST
LOOP WHILE READNEXT BIN FROM BIN.LIST DO
...
REPEAT
Please note that you shouldn't use this method if you need to access associated multi-values. For example, if REC<79> has Bin Numbers, and REC<80> has the product in that bin, and REC<81> has the quantity, you would still need to use a loop index to access all three. However, you could still improve performance using Kevin's example, as follows:
BIN.LIST = REC<79>
PROD.LIST = REC<80>
QTY.LIST = REC<81>
BIN.CNT = DCOUNT(BIN.LIST,@VM)
FOR BIN.LOOP = 1 TO BIN.CNT
BIN = BIN.LIST<1,BIN.LOOP>
PROD = PROD.LIST<1,BIN.LOOP>
QTY = QTY.LIST<1,BIN.LOOP>
...
NEXT BIN.LOOP
Logged
Pages: [
1
]
Go Up
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General Category
-----------------------------
=> Getting To Know You
=> Announcements
=> Big Thoughts / Cool Ideas
=> Rants & Raves
-----------------------------
Application Support
-----------------------------
=> Red Leaf
=> Activant/Prelude Support
=> Summit Support
=> Avante Support
=> PRC Support
-----------------------------
Training and Education
-----------------------------
=> Connect!
=> U2 Programming Questions
=> SB+ Programming Questions
=> Web Programming Questions
=> Business Intelligence / MITS
=> PC / Hardware / Miscellaneous Support
Loading...