update statistics while inserting data
Posted in 2004
Topics: Performance & Tuning
Hi, We have a database where data is being inserted continiously (at least once every 15 minutes) and which has to be up all of the time (24/24). The tables are fragmented per day. We now stop the inserts during the weekend to update the statistics, but by the end of the week performance degrades drastically - so we would like to run an update stats during the week, but we cannot stop the inserts to do this. Is it possible to update the stats while quite a lot of data is being inserted? Did anybody face & solve such problem before or has any advice? We are using IDS9.40 on HP/UX and Linux. Thanks in advance, Koen.
Actually you can fool the optimizer by bumping up nrows, but only if you are user informix. For example we have a large insert operation that starts with an empty table, inserts huge numbers of records while re-reading some of it. It used to take ages to run. This is because the program had select statements prepared and therefore query-planned on an empty table, so running update statistics during the program run would not affect performance at all. So what we did was create a stored procedure which MUST be owned by user informix, to update the nrows value to 2000 on specific tables, to fool the optimizer into using the indexes for selects. Execute the procedure on the empty table before the process starts. When the process has finished, you must run update statistics again to give it correct values, plus other info such as sysindexes, sysrocplan, sysdistrib etc.