473,396 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Scalar sub query in db2

In oracle, there is a performance improvement if scalar subqueries are
used instead of joins. Does this hold good for Db2 (8.2) too?

Aug 26 '08 #1
2 4196
ns******@gmail.com wrote:
In oracle, there is a performance improvement if scalar subqueries are
used instead of joins. Does this hold good for Db2 (8.2) too?
Inherently a scalar subquery is not a join.
I.e. a scaar subquery will raise an error if more than one match is
found. You cannot (easily) model that with an OUTER JOIN (you need the
OUTER to handle the NULL)

DB2 will convert scalar subqueries to outer joins (with some spice added
for semantics as noted above) at its own discretion.
So obviously in DB2 a scalar subquery is far from "always better".

Cheers
Serge


--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Aug 26 '08 #2
>In Oracle, there is a performance improvement if scalar subqueries are used instead of joins. Does this hold good for Db2 (8.2) too? <<

I don't think that statement is true in general for any SQL product.
There are two kinds of scalar subqueries:

1) evaluates to a constant -- (SELECT MAX(a) FROM Foobar) AS big_a

2) correlated to a containing query -- (SELECT MAX(a) FROM Foobar AS F
WHERE F.x = G.x) AS big_a_in_G

Then you can put them in the FROM clause or the SELECT clause, etc. If
I have a clustered table in Oracle, joins are already done, etc. There
are too many options for a general statement like that.
Aug 27 '08 #3

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

Similar topics

2
by: Mountain Man | last post by:
Hi, I have an array derived from a set of radio buttons that I want to break down into a single variable for use with a database. How can I do this? $gender is the array, and I want $gender2 to...
7
by: Steve Jorgensen | last post by:
Hi all, I've been using scalar functions as a way to perform some complex data transformation operations, and I've noticed that scalar functions reaaaaalllllyyyy sloooowwwwww thiiiiiings...
5
by: Bob Stearns | last post by:
When I run the following query with the two sections commented out, the response time is between 1 an 2 seconds; with the first indicated section enabled, the response goes up to 15 seconds even...
2
by: martin | last post by:
When I execute Scalar and it finds no data,it cannot be trapped. Function with scalar returns nothing instead of value in catch statement.
1
by: dtalas | last post by:
Hi all I'm having a problem where calling scalar stored procedures always returns NULL. I have the simple test stored procedure, that returns a single integer: ALTER PROCEDURE dbo.Test AS
0
by: Rayne | last post by:
I've got some scalar functions defined in sql server 2005. In VB.NET they are set up as stored procedures that return a single value in my tableadapter. When I preview data on the query in design...
2
by: mcleana | last post by:
I have a view that contains a complex query. A few of the columns call a function that returns a specific output. I also use a function to do a join as well. For example: SELECT l.ID,...
1
by: Sanjeev | last post by:
Hi Gurus, I have table (CallByCall) with following Data. Input : CallID Event DNIS UserID Time SeqID MobNo -----------------------------------------------------------------------------...
4
by: pavanponnapalli | last post by:
hi, I need to send some values to a subroutine where i use insert query. suppose say my scalar is as follows: my ($name,$number,$address) etc and i get the values into those...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.