If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
I have a statment that sometimes takes too long to or not complete at all:
"Select auth_id from db2inst1.datamodel order by auth_id desc fetch first 1 rows only optimize for 1 rows"
There is an index that exists for auth_id and the explain plan reveals that the index is being used. The table datamodel isn't very big and has only 500 some rows in it.
Would it be better for performace to NOT use the optimize for clause in this situation?
The access plan for all the 3 statements (MAX(auth_id), without Optimize clause and with optimize clause) reveals the exact same estimated cost.
I ran application snapshot and db2pd to collect some information and found out that this particular statement (the originial one with 'Optimize for' clause) has way over 300,000 NumRef and NumExec.
What I'm wondering is why DB2 chooses an index access for a table with just 500 rows. If the table doesn't have many columns (which I don't know), a table scan may be an option as well. Do you have current statistics?
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
The only column being selected is auth_id, which is in the index for the PK and there is no WHERE clause. So DB2 can satisfy the query with "index only" access, although it will scan all the leaf pages of the index instead of using the b-tree.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390