Solved

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

Posted on 2010-08-25
6
614 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

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 (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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

729 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