How to make MYSQL Query faster

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jonnyyadav
    New Member
    • Apr 2013
    • 3

    How to make MYSQL Query faster

    This query is taking 3 minutes to execute it. pls healp me to make it faster.
    Code:
    select histpric.timetick, stcurr.externalid, stcurr.assetid,stcurr.asset_name,bsnshistpr.bse_price,
    bsnshistpr.nse_price, histpric.eod_price 
    from bse_current as stcurr join Stock_Hist_Price_2013 as histpric on stcurr.assetid = histpric.assetid  
    join BSE_NSE_Hist_Price_2013 as bsnshistpr on stcurr.assetid = bsnshistpr.assetid 
    and histpric.timetick = bsnshistpr.timetick 
    where  histpric.timetick >= '2013-03-04' and  histpric.timetick <= '2013-03-04'
    order by stcurr.assetid Asc;
    Last edited by Rabbit; Apr 5 '13, 04:31 PM. Reason: Please use code tags when posting code.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Use EXPLAIN http://dev.mysql.com/doc/refman/5.0/...g-explain.html and identify appropriate indexes to create and use.

    Comment

    • jonnyyadav
      New Member
      • Apr 2013
      • 3

      #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.bs nshistpr.asseti d 1 Using where

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        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.

        Comment

        • jonnyyadav
          New Member
          • Apr 2013
          • 3

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

          Comment

          Working...