?
Solved

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

Posted on 2010-08-25
6
Medium Priority
?
615 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 46

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 46

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

Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

Question has a verified solution.

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

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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

800 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