HI Jaroslaw,
this is definately the wrong way.
First, delete the query plan in dbacockpit, to ensure that the SQL Server will generate it again.
After this, wait again until the statement is called, to analyse the query plan.
Check if traceflags are set: 617,1117,1118,2371
i'm not 100%sure but i guess the 2371 is for a generic calculation of auto update statistics, depending on the size of the table and the changed data. So this is an imporant one if the DB is using the correct index, but after time choosing the wrong.
Check the fragmentation of the clusted index in dbacockpit. If it is higher then 40-50%, rebuild the indexes. I solved a problem that the query optimizer is choosing the wrong index doing this.
If you problem occours in an non standard program (Y* Z*), you maybe can work with database hints in abap code (but these are very rare cases). If this is a standard program, check if there is a note.
I had a problem, where a note added a database hint to solve a problem like this. Just search for the reportname in sapsupport.
Maybe you can show us the indexes of the table, the abap statement and the query plan.
Regards
Manuel
Message was edited by: Manuel Herr