title: Batch select statements are taking long time to return result with one row in MS SQL database
body: <p>We are facing an issue with one of our java batch jobs. At some time the job takes too much time to finish. We can see the query exection for one particular query is taking long time(~5 sec).</p>
  
  <p>But this will get fixed once we run <code>UPDATE STATISTICS</code> in database.</p>
  
  <p>Could anyone please explain what would be the reason for this? IF we execute the same query from SQL tool, it will finish in micros seconds.</p>
  
  <p>Below is the query
  'SELECT x.PK FROM (SELECT  item_t0.PK  FROM pricerows item_t0 WHERE ( item_t0.p_productmatchqualifier  in (?, ?) and  item_t0.p_usermatchqualifier  in (?, ?, ?)) AND (item_t0.TypePkString=? AND ((   item_t0.p_product  IS NOT NULL OR item_t0.p_catalogversion  IS NULL OR  item_t0.p_catalogversion  IN (?) ))) UNION SELECT  item_t1.PK  FROM pricerows item_t1 WHERE ( item_t1.p_productmatchqualifier =? and  item_t1.p_productid =? and  item_t1.p_usermatchqualifier  in (?, ?, ?)) AND (item_t1.TypePkString=? AND ((   item_t1.p_product  IS NOT NULL OR item_t1.p_catalogversion  IS NULL OR  item_t1.p_catalogversion  IN (?) )))) x</p>