title: Why does the same query takes different amount of time to run?
body: <p>I have this problem that has been going on for months. I automate reports at my job, we use oracle. I write a procedure, time it, it runs in a few minutes. I then set it up for monthly runs.</p>
  
  <p>And then every month, some report runs for hours. It's all the same queries that ran in a few minutes for months before and all of a sudden they're taking hours to run.</p>
  
  <p>I end up rewriting my procedures every now and then and to me this defeats the purpose of automating. No one here can help me. </p>
  
  <p>What am I doing wrong? How can I ensure that my queries will always take the same amount of time to run.</p>
  
  <p>I did some research and it says that in a correctly setup database with correct statistics you don't even have to use hints, everything should consistently run in about the same time.</p>
  
  <p>Is this true? Or does everyone have this problem and everyone just rewrites their procedures whenever they run?</p>
  
  <p>Sorry for 100 questions, I'm really frustrated about this.</p>
  
  <p>My main question is, why does the same query takes different amount of time (drastic difference, from minutes to hours) to run on different days?</p>