title: PostgreSQL select query loading issue some time only?
body: <p>This query loads some time and take 1 minute to complete, that time we remove the 'user_action_id' it completed with in millisecond. Most of the value in the 'user_action_id' is null.</p>
  <pre><code>select sum(Round(((cast((bd.posi_loose/u.uom_max_loose) as numeric))+bd.quantity)*bd.price,2)) 
  into totalAmountInItemVoid
  from t_bill_details bd
  left join public.c_terminal trml on trml.id=bd.terminal_id
  left join public.t_bill bil on bil.id=bd.bill_id and bil.terminal_id=bd.terminal_id
  left join public.c_uom u on u.id=bd.uom_id
  where bil.status!=7 
    and bil.status!=9 
    and bd.user_action_id=2 
    and bil.created_by=userid 
    and bil.eod_businessday_id is null;
  </code></pre>