title: Why my sql query is so slow in one database?
body: <p>I am using sql server 2008 r2 and I have two database, which is one have 11.000 record and another is just 3000 record, when i do run this query</p>
  
  <pre><code>SELECT Right(rtrim(tbltransac.No_Faktur),6) as NoUrut,
         tbltransac.No_Faktur,
         tbltransac.No_FakturP,
         tbltransac.Kd_Plg,
         Tblcust.Nm_Plg,
         GRANDTOTAL AS Total_Faktur,
         tbltransac.Nm_Pajak,
         tbltransac.Tgl_Faktur,
         tbltransac.Tgl_FakturP,
         tbltransac.Total_Distribusi 
  FROM Tblcust
    INNER JOIN ViewGrandtotal AS tbltransac ON Tblcust.Kd_Plg = tbltransac.Kd_Plg 
  WHERE tbltransac.Kd_Trn = 'J'
    and year(tbltransac.tgl_faktur)=2015
    And ISNULL(tbltransac.No_OPJ,'') &lt;&gt; 'SHOP'  
  Order by Right(rtrim(tbltransac.No_Faktur),6) Desc
  </code></pre>
  
  <p>It takes me 1 minute 30 sec in my server (I query it using sql management tool) that have 3000 record but it only took 3 sec to do a query in my another server which is have 11000 record, whats wring with my database?</p>
  
  <p>I've already tried to backup and restore my 3000 record database and restore it in my 11000 record server, it's faster.. took 30 sec to do a query, but it's still annoying if i compare to my 11000 record server. They are in the same spec</p>
  
  <p>How this happend? what i should check? i check on event viewer, resource monitor or sql management log, i couldn't find any error or blocked connection. There is no wrong routing too..</p>
  
  <p>Please help... It just happen a week ago, before this it was fine, and I haven't touch the server more than a month...</p>