Is it possible that the frequency of rebuilding indexes (which automatically triggers statistics update) can affect the query logic?

One of the developers I work with claims that a stored procedure failed (there was a type conversion error) because the statistics have not been up to date during the query execution and it used the wrong query plan. He also claims that after having updated statistics the procedure works fine.

Is it even possible?

  • 2
    Without more detail, such as the definitions of the tables, stored procedures, and statistics, etc, it will be quite difficult to help you.
    – Hannah Vernon
    Apr 7, 2015 at 13:02
  • @MaxVernon I am pretty sure there is a problem with the stored procedure and I'm going to fix it when I see its definition. My question is not very specific because I don't want you to help me correct the error. I want to know if it is possible - theoretically that different plans mean different data manipulation and type mismatch errors.
    – BuahahaXD
    Apr 7, 2015 at 15:28

1 Answer 1


At least I think it is possible that the procedure gets a different plan and that way it doesn't touch the rows that have "invalid" data, for example numbers or dates stored as varchar that aren't correct and then conversion logic in the procedure.

For example if you're fetching with both date range and customer code, and some of the data for that customer causes the error, but is outside the date range -- so, if the plan uses date range, it works ok, but if it fetches all the rows for the customer, then does something related to the conversion and then last compares the date range, then it fails.

I haven't tested this, but I would assume that could happen, but of course the data / procedure should be fixed.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.