By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,650 Members | 753 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,650 IT Pros & Developers. It's quick & easy.

How to make MYSQL Query faster

P: 3
This query is taking 3 minutes to execute it. pls healp me to make it faster.
Expand|Select|Wrap|Line Numbers
  1. select histpric.timetick, stcurr.externalid, stcurr.assetid,stcurr.asset_name,bsnshistpr.bse_price,
  2. bsnshistpr.nse_price, histpric.eod_price 
  3. from bse_current as stcurr join Stock_Hist_Price_2013 as histpric on stcurr.assetid = histpric.assetid  
  4. join BSE_NSE_Hist_Price_2013 as bsnshistpr on stcurr.assetid = bsnshistpr.assetid 
  5. and histpric.timetick = bsnshistpr.timetick 
  6. where  histpric.timetick >= '2013-03-04' and  histpric.timetick <= '2013-03-04'
  7. order by stcurr.assetid Asc;
Apr 5 '13 #1
Share this Question
Share on Google+
4 Replies


10K+
P: 13,264
Use EXPLAIN http://dev.mysql.com/doc/refman/5.0/...g-explain.html and identify appropriate indexes to create and use.
Apr 5 '13 #2

P: 3
this is the result i have got. i did not understand what it means.
1 SIMPLE histpric ALL 196480 Using where; Using temporary; Using filesort

1 SIMPLE bsnshistpr ALL 196480 Using where; Using join buffer
1 SIMPLE stcurr eq_ref PRIMARY PRIMARY 4 mprofitmysql.bsnshistpr.assetid 1 Using where
Apr 5 '13 #3

10K+
P: 13,264
The EXPLAIN output is explained here http://dev.mysql.com/doc/refman/5.6/...in-output.html

You will need to read about indexes as well if you don't know what they are.
Apr 5 '13 #4

P: 3
thanks for the reply. making indexes to my columns really made my o/p very faster in 2-3 seconds. thnaks a lot...
Apr 5 '13 #5

Post your reply

Sign in to post your reply or Sign up for a free account.