I am optimizing some server application task that uses database (querying, complex calculations, data insertions...). Execution of this task spends about 16 minutes (I have tested it 3 more times) and it predictable time to do it.
Then I executed script:
ALTER INDEX ALL ON dbo.'+ @TableName +' REBUILD
for every table in a database. And what I see now. The time of execution my task is increased to 24 minutes. What's going on if these is not any external influences on this task? I was waiting for increasing of performance (due rebuilding fragmented indexes) but got degradation.