Solved

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

Posted on 2010-08-25
6
605 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
Comment Utility
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:Kdo
Comment Utility
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 24

Author Comment

by:Tomas Helgi Johannsson
Comment Utility
      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:Kdo
Comment Utility

Hi Tomas,

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


Kent
0
 
LVL 24

Accepted Solution

by:
Tomas Helgi Johannsson earned 0 total points
Comment Utility
        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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now