Help optimizing a query

Reply

Join Date: Feb 2008
Posts: 6
Reputation: bernardf is an unknown quantity at this point 
Solved Threads: 0
bernardf bernardf is offline Offline
Newbie Poster

Help optimizing a query

 
0
  #1
Dec 10th, 2008
Hi there,

Can someone please help me in optimizing a query.

The query that I have is as follows:

  1. CREATE TABLE RED_WINE_TXN AS
  2. SELECT MEMBER_SEQUENCE, SUM(PURCHASE_VALUE) PURCHASE_VALUE, SUM(QUANTITY) QTY
  3. FROM PURCHASE_DETAILS a, RED_WINE_SKUS b
  4. WHERE a.PRODUCT_NO=b.PRODUCT_NO
  5. AND TRANSACTION_DATE>=20071101
  6. GROUP BY MEMBER_SEQUENCE

MEMBER_SEQUENCE: DECIMAL (INDEX)
PURCHASE_VALUE: DECIMAL
QUANTITY: DECIMAL
PRODUCT_NO: DECIMAL (INDEX ON BOTH TABLES)
TRANSACTION_DATE: DATETIME

If anyone knows what steps I should take to speed this up that would be great.

Thanks, Bernie
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 823
Reputation: verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough 
Solved Threads: 73
verruckt24's Avatar
verruckt24 verruckt24 is offline Offline
Practically a Posting Shark

Re: Help optimizing a query

 
0
  #2
Dec 10th, 2008
Use EXPLAIN followed by your query to get an explanation about the query from MySQL. Then you can analyze this output to know how your query is performing, then based on this you can optimize your query accordingly.

Suggestion : Use the Internet to your advantage, you could have as easily found this out from the net if you would have taken the pains to search the net.
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC