Access the answers to your technology questions today.
Subscribe Now
30-day free trial. Register in 60 seconds.
What Makes Experts Exchange Unique?
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.
Try it out and discover for yourself.
Subscribe Now
30-day free trial. Register in 60 seconds.
Join the Community
Give a Little. Get a Lot.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Join the Community
by: yessirnosirPosted on 2007-08-29 at 18:25:29ID: 19796847
Right now does your "Explain" output show type as "ALL", i.e. that the query must read ALL the rows of your table? I think if you add indexes for the columns in your WHERE clause, you can reduce that substantially. If you index StoreID then the query would only look at the rows from those three stores. If you additionally index Completed, the query narrows it down to only completed orders at those stores. I'm not sure if there is any benefit in indexing product ID in the having clause. But one could easily imagine doing other queries on particular products, customers, orders, or stores, so in the absence of any other info about what you're trying to do, I'd probably put an index on all four of those columns. That would marginally slow down Inserts, but would greatly speed up Selects.
.com/featu res/mysql/ article.ph p/ 10897_13 82791_1
Here's a pretty good discussion of MySQL indexes http://www.databasejournal