473,663 Members | 2,854 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

access plan when view has rank()

I discover next problem

I have view definition with rank()

create view vTEST as
select c1, c2, c3, ...
-- problem area start
, rank() over (order by c3) as RNK
-- problem area stop
from table
where [low selectivity predicates: c4=v1 and c5=v2 ]

when I do :
select * from vTEST where C1 = :value;

access plan and query is very poor, because predicate C1=value doesn't
used db2. When I do simple select like view definition predicate
C1=value used and query work fine! Identically select and view has
different access plan... Selectivity clause doesn't work with view.

select * from vTEST where C1 = :value
will also work fine if I remove column definition with rank() function.

Tested on DB2 8.2 fixpack 7 and 8 under win32

Bug or feature?

Andy
bughunter

Nov 12 '05 #1
3 2160
bughunter@ru wrote:
I discover next problem

I have view definition with rank()

create view vTEST as
select c1, c2, c3, ...
-- problem area start
, rank() over (order by c3) as RNK
-- problem area stop
from table
where [low selectivity predicates: c4=v1 and c5=v2 ]

when I do :
select * from vTEST where C1 = :value;

access plan and query is very poor, because predicate C1=value doesn't
used db2. When I do simple select like view definition predicate
C1=value used and query work fine! Identically select and view has
different access plan... Selectivity clause doesn't work with view.

select * from vTEST where C1 = :value
will also work fine if I remove column definition with rank() function.

Tested on DB2 8.2 fixpack 7 and 8 under win32

Bug or feature?

Andy
bughunter

Feature. You are not comparing apples to apples.
The equivalent select is:
select * from
(select c1, c2, c3, ...
-- problem area start
, rank() over (order by c3) as RNK
-- problem area stop
from table
where [low selectivity predicates: c4=v1 and c5=v2 ]) AS X
WHERE where C1 = :value

Lets' assume c1 is a primary key (for arguments sake), then
RNK would always be 1 if c1 were pushed down.
However RNK could be any number between 1 and #rowsintable without the
pushdown.

If you want to push the predicate down you may want to consider using an
SQL table function:
CREATE FUCNTION vTEST(INT c1_arg) RETURNS TABLE (....)
READS SQL DATA
RETURN SELECT(select c1, c2, c3, ...
-- problem area start
, rank() over (order by c3) as RNK
-- problem area stop
from table
where [low selectivity predicates: c4=v1 and c5=v2 ]) AS X
AND C1 = c1_arg;

SELECT * FROM TABLE(vtest(:hv )) AS V;

That should give you a good plan.

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2
Thanks, Serge!

What about another constructions where select and select from view will
have different access plan?

Andy

Nov 12 '05 #3
bughunter@ru wrote:
Thanks, Serge!

What about another constructions where select and select from view will
have different access plan?

Andy

The common case is that there is a semantic reason whenever the
injection of a view has a detrimental effect.
There are exceotions, but ther are far and few between ( and I don't
know them off hand). Personally I treat them as optimization bugs.

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
1852
by: CJM | last post by:
I have a query which produces different results in the Access query builder and in an ASP page (via ADO) An example of the query is: ---------------------------------------------------------- Select 'Ranked' as Source, H.HotelName, H.TelNo, H.URL, H.Location, H.HotelID, Rank from (Hotels H Inner Join PrefHotels P on H.HotelID = P.HotelID) Inner Join Locations L on P.LocID = L.LocID where Rank is not null and Rank > 0 and L.LocID=2
14
5406
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB 7.2 environment, the choices the optimizer makes often seem flaky. But this last example really floored me. I was hoping someone could explain why I get worse response time when the optimizer uses two indexes, than when it uses one. Some context:
2
1879
by: Fan Ruo Xin | last post by:
Can someone help me to confirm - From the access plan tree of a query, if one table is referred (TABLE SCAN) three times. Does that mean this table was scanned (either from disk or bufferpool) three times during runtime? TIA FRX
6
4457
by: Jarrod | last post by:
I have multiple reports in one database, on one form. I need to know what reports were run when, and by Network User ID. How do I do that?
92
7634
by: Jeffrey P via AccessMonster.com | last post by:
Our IT guys are on a vendetta against MS Access (and Lotus Notes but they've won that fight). What I can't understand is, what's the problem? Why does IT hate MS Access so much. I have tried to find out who it is that actually wants to get rid of it, but I can't find anyone who will admit to trying to get rid of it. Nevertheless, I'm always hearing about how their "phasing it out" or "getting rid of it". Because no-one owns up I can't...
0
683
by: Jerry | last post by:
Below is ALL the code for all the databases... Here's the problem: I callup the aspx file in IE and the form comes up just fine. When I select a person to update, I get the subject error. Aparently, when I select a person, it's not selecting anyone and returning this error. Here's the full error: Description: An unhandled exception occurred during the execution of the
2
6544
by: Robert Smith jr. | last post by:
Hello, Please pardon my newbie question ... I am building an ASP.NET page that displays a recordset with a Delete statement enabled (this all works fine). I want to Insert the current row *that is going to be deleted* into another table, before the original data is deleted. I am trying to use the RowDeleting method to call an Update or Insert
6
3861
by: Bob Alston | last post by:
I am looking for others who have built systems to scan documents, index them and then make them accessible from an Access database. My environment is a nonprofit with about 20-25 case workers who use laptops. They have Access databases on their laptops and the data is replicated. The idea is that each case worker would scan their own documents, either remotely or back at the office. And NO I am not planning to store the scanned...
2
2401
by: kevinlhamiltonsr | last post by:
INSERT INTO ( CC, HeldPayAccounts, ASG, , Command, OrderNo, , ) SELECT .CC, .HeldPayAccounts, .ASG, ., .Command, .OrderNo, . AS Expr2, (Select count(.) from as where ((. >= .) and (. = .))) AS Rank FROM GROUP BY .CC, .HeldPayAccounts, .ASG, ., .Command, .OrderNo, . ORDER BY .OrderNo; The above statement is in MS Access 2003 SQL view of Query. Some where I need to add the "Select ROW_NUMBER() over (Partition by item order by...
0
8436
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8858
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8771
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8548
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7371
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5657
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2000
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.