469,936 Members | 2,466 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,936 developers. It's quick & easy.

How to make MYSQL Query faster

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
4 1896
13,262 8TB
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
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
13,262 8TB
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
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.

Similar topics

3 posts views Thread by joemyre | last post: by
7 posts views Thread by YoBro | last post: by
reply views Thread by Murphy | last post: by
2 posts views Thread by laredotornado | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.