想问一下,runstats on table tablename with distribution and detailed indexes all同时表有新增和更新操作有影响吗,看了下runstats的时候表上的IN锁正常来说应该是对insert、update这些操作不影响的吧
Re: 通常情况下不影响. 请参考如下官方解释:
- When you start running the RUNSTATS command, it acquires an IX table lock on the SYSTABLES table and a U lock on the row of the table on which you are gathering statistics. Operations can still read from the SYSTABLES table, including the row in the table with the U lock. Write operations are also possible if they do not occur against the row with the U lock. However, another reader or writer cannot acquire an S lock on the SYSTABLES table because of the IX lock that the RUNSTATS command acquired.
还想问下新增索引时是不是数据库默认就会执行runstats,没必要再执行一次1.
RE: 这个要看数据库automatic maintennance 中 parameter “AUTO_TBL_MAINT” 设置 , 通常情况增加index后, 建议手动 runstatus 来 update statistics