Look at this scenario (kindly provided to me by my collegue Lisa).
You have a session table that contains all the user sessions, so one row for each login session.
If you want to execute runstats on this table you should run when there is the peek of users logged, otherwise if you do when there are a few of users logged then you get a low cardinality number in the statistics catalog. The problem is that runstats are generally run when the system is quiet, during the night because it is a CPU and disk intensive operation, so it is not possibile to get the maximun cardinality because there are not many users in the session table at the night.
Then when the cardinality is low DB2 will prepare an access plan with a table scan even if there is an index, because if it would be faster. This is true in the case of a small table when all the data fits on one data page only in DB2, then table scanning is faster than using an index.
update sysibm.sysindexes set indcard=10 where name='MYINDEX'
Instead if you want to force the access plan to use the index change the cardinality of the table, execute an update statement to set the maximum number of rows (of the peek hours) on the statistics without the need to run runstats.
update sysibm.sysindexes set indcard=10000 where name='MYINDEX'
This blog covers different aspects around software development and test. There are also general information useful for who needs to test performances and needs to analyze bottlenecks on application servers and databases. Disclaimer: test before you implement any advice, no warranty is provided. Before use the software mentioned in this blog read and understand all licenses agreements. Use of the information contained in this blog is under your own responsibility.
venerdì 27 febbraio 2015
Iscriviti a:
Commenti sul post (Atom)
Nessun commento:
Posta un commento