Hey all,
I am designing a web-based 12-column sales report that will display 12 user specified periods across the top, items down the left, and the total sales for each period. The report will also suggest an order quantity based on sales. It is great for tracking how well an item was maintained (i.e. an item that was selling 100 / week suddenly drops to
0....oops!). The program will also allow users to set order reminders, and even place their order from the report.
Anyway, it will be nice. The problem is that the report takes about 30 seconds per manufacturer for three months of data. Not very efficient to be sure...
There are a number of queries in the program, most fairly simple. However, here is the one that is clocking 22 seconds...
SELECT i.Description, i.ID, i.Price, i.Cost, s.ReorderNumber, sum(te.Quantity) AS Quantity, sum(te.Quantity * te.Price) AS Dollars FROM Item i, SupplierList s, TransactionEntry te, [Transaction] t WHERE i.ID=s.ItemID AND item.ID=te.ItemID AND te.TransactionNumber = t.TransactionNumber AND s.SupplierID = {variable from program} AND t.Time BETWEEN '{variable1}' AND '{variable2}' GROUP BY i.Description, i.ID, i.Price, i.Cost, s.ReorderNumber ORDER BY s.ReorderNumber ASC
I am wondering if it wouldn't hurt to create some indexes to cover this query. Also, I am not familiar with any efficiency variances between types of JOINS. As you can see, I am using only symbolic joins. I noticed that Microsoft tends to favor INNER JOINS and the like, but in my mind they accomplish the same thing. I tend to be more on the web development side of things rather than the database development side, so pardon any SQL etiquette errors.
Also, if there are any syntax errors, this isn't a direct copy from the program, I am typing it from memory as I don't have it right in front of me.
So, what can I do to speed this up?
Thanks in advance!
-- Alex Nielsen