Now and then I must look at how long processes are running. Our web applications should be all running in under 500 milliseconds even though there are a lot of records in the database. An important datatable loading program on our web form was taking upwards of 2 seconds to load. I tested it on our development machine and with the client's data and the same number of indexes (7) and found our SELECT times were about the same. The PICKUP.DATE and ORIGIN.TERM are all indexed fields. Obviously, the SELECT optimizer does not work like I think it does.
Here is the test code abbreviated that runs in 643 milliseconds
TERMINAL.NO = "059" ; BEGIN.DATE = "06/24/2023" ; END.DATE = "06/30/2023"
LINE = 'SELECT MOVE.LOADS'
LINE := ' WITH PICKUP.DATE GE "':BEGIN.DATE:'"'
LINE := ' AND WITH PICKUP.DATE LE "':END.DATE:'"'
LINE := ' AND WITH ORIGIN.TERM = "':TERMINAL.NO:'"'
EXECUTE LINE CAPTURING OUTPUT
LOOP WHILE READNEXT ID
READ LD.ITEM FROM MOVE.LOADS,ID ELSE CONTINUE
REPEAT
Here is the 7 times faster code that runs in 89 milliseconds
TERMINAL.NO = "059" ; BEGIN.DATE = "06/24/2023" ; END.DATE = "06/30/2023"
LINE = 'SELECT MOVE.LOADS'
LINE := ' WITH PICKUP.DATE GE "':BEGIN.DATE:'"'
LINE := ' AND WITH PICKUP.DATE LE "':END.DATE:'"'
EXECUTE LINE CAPTURING OUTPUT
LOOP WHILE READNEXT ID
READ LD.ITEM FROM MOVE.LOADS,ID ELSE CONTINUE
IF LD.ITEM<7> # TERMINAL.NO THEN CONTINUE
REPEAT
Posted: 07-14-2023 11:27
------------------------------
Doug Averch
Owner
U2 Logic
------------------------------




