I need to loop on InventTrans to cumulate itemId quantities for some dates and populate a temp table with the results in a form using this temp table as datasource. I used a class and the process is quite long (about 5-10 seconds) for an itemId.
Which code is fastest?
- using a class that does the process
- methods on the temp table
- process with a button clicked() on the caller form
How can I improve my code?
As you do not show your code, improving on it will be purely speculative.
I would rule out number 3 entirely; putting business logic in clicked methods is not an option.
Things to consider:
serverkeyword on the table method or class static method (or use class property). Avoid call back to client for parameters etc.insert_recordset.InventSumtable may have the data ready for you. Use thesumkeyword in the select, combined with join on theInventDimtable. Consider making a view to do the hard work. This will make the SQL server do the calculation, which typically results in a two-digit factor increase in performance.Long queries? Enable SQL logging of long queries in your user settings.
What is the time spent on? Use the code profiler.