Re: sysprocplan ??
Posted in 2003
Hi, the order of an UPDATE STATISTICS is not neccessarily important. I would suggest to make use of SET LOCK MODE TO WAIT nseconds ! Whenever you invoke a Stored Procedure, the server first looks inside its plan if it is neccessary to re-optimize the stored procedure. This lookup doesn't place an Excusive Lock on sysprocplan, it's only a Shared Lock. But, the reoptimization becomes neccessary if the statistics for any table mentioned inside the procedure changed. This implicit reooptimization will place an eXclusive lock on the sysprocplan table and another user will be unable to invoke the same procedure, until the eXclusive lock is released. If you would first run update statistics for all tables mentioned in the Stored Procedure, the first call of the SP would update the statistics for the procedure. If you would first update the statistics for the procedure, then run update statistics for the tables, the next invocation of the SP will automatically update it's own statistics, because the statistics of the tables changed since the last update statistics of the SP. And you cannot do anything against this mechanism. Keep transactions short - as Eric explained - and make use of "SET LOCK MODE TO WAIT nsecs" ! BR Stefan