Solved

Strange view behavior in DB2 v9.1 z/OS - Queries hangs when executed

Posted on 2010-08-25
6
610 Views
Last Modified: 2012-05-10
        Hi!

I reasently added a view that has a function in it that takes one column and decrypt it's data using the crypto facilty of our Mainframe and presents the decrypted data in the view.
I'm seeing some strange behavior how DB2 handles the view when selecting data from it.
We have tried severeal different sql statements that DB2 should use index-scan (as it does with the view we are trying to replace).
Instead the explain of the view shows tablescan and the queries hangs. The table behind the view has around 1.4 million rows with one encrypted column.
RMF data from the crypto facility shows that utilization (%) of 1 of 4 crypto coprocessors goes from 0.5 % up to 48.4 % on a 10 minute interval for just 4 sql queries that we executed.
Any ideas what could cause this ?
The only difference lies in the view where one column is decrypted in the view. Running the queries on the new view results in tablescan while the old view has index scan on all the same queries.

Regards,
    Tomas Helgi
0
Comment
  • 2
  • 2
6 Comments
 
LVL 37

Expert Comment

by:momi_sabag
ID: 33520376
hi tomas
is the column you are decrypting a part of the index?
if not, maybe the original view performs an index only scan, but the new view needs to also access the table, so db2 figures out it is better off with a full table scan
0
 
LVL 45

Expert Comment

by:Kent Olsen
ID: 33520389
Hi Tomas,

It would appear that the optimizer is determining that a significant number of rows in the table will be required and therefore not using the index.  

If the number of rows is modest, try selecting the primary key of the target rows, forcing an index scan, and joining the table back to the selected keys.


Kent
0
 
LVL 25

Author Comment

by:Tomas Helgi Johannsson
ID: 33520872
      Hi!

We tried adding an index with the encrypted column without success. DB2 doesn't choose the index. :(
Also trying to select only the primary key columns with  those columns in where clause  then the explain shows that the
whole query has a combination (first queryblock) of tablescan (the view itself) as well as index-scan (second query block) and a cpu cost around 37 (CPU ms) and 682 (CPU su).
When both queryblocks shows tablescan then we get CPU Cost (ms) 5920 and CPU Cost (su)  109623.  :S

Regards,
    Tomas Helgi
0
 
LVL 45

Expert Comment

by:Kent Olsen
ID: 33520914

Hi Tomas,

Can you post the query in the view and a perhaps the table/index definitions?


Kent
0
 
LVL 25

Accepted Solution

by:
Tomas Helgi Johannsson earned 0 total points
ID: 33521047
        Hi!

We found out what it was. The function was created with the keyword non deterministic instead of deterministic. :)
After dropping the view and function and recreating the function with appropriate keywords and view we get the same
result in both the orginal and the new view.

Regards,
   Tomas Helgi
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question