473,734 Members | 2,647 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Federated DB Bad Query performance

I have a query running on a federated database that takes the form

select col1, col2
from nickname1
where <conditions exist>

union all

select col1,col2
from nickname2
where <conditions exist>
Nickname1 refers to a table on my primary database. Nickname2 refers
to an identically structured table in my secondary database.

The performance for this query is abysmal. I found the bottleneck to
be the second half of the query referencing nickname2. However, if I
connect to the secondary database directly and access the table with
the same query (bypassing the federated layer), the performance is
lightning fast.

The plan for the nickname2 piece uses a lot of SHIP and MSJOINs, where
the plan for nickname 1 uses hash joins. Statistics are up to date on
both primary and secondary databases. I need to figure out how to make
the federated layer choose a better plan. Any clues?

Using 8.2 FP14 on AIX 5.3

Thanks,
Evan

Oct 31 '07 #1
4 4618
esmith2112 wrote:
I have a query running on a federated database that takes the form

select col1, col2
from nickname1
where <conditions exist>

union all

select col1,col2
from nickname2
where <conditions exist>
Nickname1 refers to a table on my primary database. Nickname2 refers
to an identically structured table in my secondary database.

The performance for this query is abysmal. I found the bottleneck to
be the second half of the query referencing nickname2. However, if I
connect to the secondary database directly and access the table with
the same query (bypassing the federated layer), the performance is
lightning fast.

The plan for the nickname2 piece uses a lot of SHIP and MSJOINs, where
the plan for nickname 1 uses hash joins. Statistics are up to date on
both primary and secondary databases. I need to figure out how to make
the federated layer choose a better plan. Any clues?

Using 8.2 FP14 on AIX 5.3
Are the predicates pushed down to the federated server?

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Oct 31 '07 #2
esmith2112 wrote:
I have a query running on a federated database that takes the form

select col1, col2
from nickname1
where <conditions exist>

union all

select col1,col2
from nickname2
where <conditions exist>
Nickname1 refers to a table on my primary database. Nickname2 refers
to an identically structured table in my secondary database.

The performance for this query is abysmal. I found the bottleneck to
be the second half of the query referencing nickname2. However, if I
connect to the secondary database directly and access the table with
the same query (bypassing the federated layer), the performance is
lightning fast.

The plan for the nickname2 piece uses a lot of SHIP and MSJOINs, where
the plan for nickname 1 uses hash joins. Statistics are up to date on
both primary and secondary databases. I need to figure out how to make
the federated layer choose a better plan. Any clues?
Are the statistics on the federated server up to date as well? The fed
server can't come up with a good plan if it has completely different
statistics than the remote data sources (what you named "primary database
and secondary database").

Could you also show us the access plan that's been generated?

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Nov 1 '07 #3
Thanks, Michael, for the tip.

I think I finally got to the root cause of the issue here. I am using
a common table expression up front. The optimizer was smart enough
before to recognize that the query could be pushed to the remote
database before materializing the results in the federated database.
It appears now that it's trying ship the entire table and materialize
it locally before getting the values.

I have validated that the statistics on the federated database are
current with the statistics on the remote database. Ironically, I
think that this is the problem. Since it was originally tested, the
remote database has undergone a thorough "cleansing" with reorgs and
runstats. I believe that the new statistics are what's tipping the
optimizer's choice in favor of shipping the data.

Which of the updatable statistics on the federated DB can I change to
"fool" the optimizer into not shipping the data? Here are the current
values:

TABLE:
-----------------------
CARD: 2695569
FPAGES: 130688
NPAGES:130688
OVERFLOW: 0
COLUMNS:
-------------------------------------
ACCKEY--HIGH2KEY: 'ZZZZZZ-0000000'
ACCKEY--LOW2KEY: ' '
CUSIP--HIGH2KEY: 'Z8065852'
CUSIP--LOW2KEY: ' '

INDEX (composite +ACCKEY+CUSIP)
-------------------------------------
CLUSTERFACTOR: 21
CLUSTERRATIO: -1
NLEAF: 87220
NLEVELS: 4
FIRSTKEYCARD: 4355185
FULLKEYCARD: 4948815
Thanks again,
Evan

On Nov 1, 4:45 pm, Michael Ortega-Binderberger <m...@ics.uci.e du>
wrote:
Hi Evan,

Runstats won't work on nicknames, but instead you can use
the nnstat utility that refreshes nickname statistics.

Nicknames use substantially the same statistics as regular
tables, they just get collected by a different mechanism
than runstats. If you can update the statistics on your
target tables, then run nnstat for the nicknames you need,
that should help.

Michael
read more »


Nov 2 '07 #4
Thanks for the suggestions again. We tried manually altering the
statistics, and set the DB2_MAXIMAL_PUS HDOWN server option as well,
but never got the execution plan we needed. In the end we chose to
materialize the rows that would have been part of the common table
expressions into temp tables, join those tables with the other
nicknames. Performance came back to the sub-second times we were used
to before "cleaning house."

Evan

On Nov 2, 2:05 pm, Michael Ortega-Binderberger <m...@ics.uci.e du>
wrote:
Hi Evan,

Of the top of my head I don't know what would change the
behavior without spending much more time on it.

Many stats are used by the nicknames besides the ones you
mention. You can play with increasing the size of the
tablecard and then also perhaps manipulating colcard (it
needs to be below tablecard for consistency).

I think that increasing the tablecard would convince the
optimizer not to ship so much data and try to do things at
the data source. Or you could try to enable the
DB2_MAXIMAL_PUS HDOWN server option (need to check the
spelling of it).

Let me know how it goes and if you need more help I wolud
suggest opening a pmr.

Michael

Nov 6 '07 #5

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

Similar topics

7
2913
by: stabbert | last post by:
I am attempting to join two tables together on two different unix servers. Here is some relevant info about the tables. TABLE 1 Setup ----------------------- DB2 UDB 7.2 EE
3
2962
by: Terry | last post by:
Hi All, Im trying to run db2expln over some sql in order to find out why its so slow. I receive the following error message. LINE MESSAGES FOR DYNEXPLN.sqc ------ -------------------------------------------------------------------- SQL0060W The "C" precompiler is in progress.
0
1765
by: Joerg Ammann | last post by:
hi, os: aix 4.3.3 DB2: version 7 FP3 we are using a federated DB setup, datasource and fed-Db are both V7FP3 (in fact they are on the same server) and are having massiv performance problems. i tracked it back to the way the queries are push-downed to the
4
606
by: uthuras | last post by:
Greetings all, Is it possible to have federated db feature implemented among DB2 family? I intend to create federated within DB2 databases. I have 2 databases TestA and TestB. I have some base tables in TestA database and the reference tables in TestB database. Now i want to select data from TestB database referencing base table in TestA database. One of the way would be Federated Database. I've seen some red books on setting up...
5
3343
by: Klemens | last post by:
I get SQL30090 reason 18 by trying to do an insert in a federated table and an update in a local table in one transaction Do I have to change some settings to get done or ist this not possible by definition? Thanks Klemens
2
1801
by: Zri Man | last post by:
I have a situation that is as follows: First an Index of what is discussed below: FED_A ->> Federated Objected/Table that has lots of rows LOC_B ->> Local Table which is selected and updated. My data flow works through a Informatica workflow and is therefore not exactly like a single transaction.
7
6569
by: P. Adhia | last post by:
Sorry for quoting an old post and probably I am reading out of context so my concern is unfounded. But I would appreciate if I can get someone or Serge to confirm. Also unlike the question asked in the post below, my question involves non-partitioned table loads. I want to know if, in general, loading from cursor is slower than loading from a file? I was thinking cursor would normally be faster, because of DB2's superior buffer/prefetch...
4
3455
by: Praveen_db2 | last post by:
Hi All DB2 8.1.3,Windows I have 2 databases in a single instance, say DB_1 and DB_2.I need to query a table from DB_1 in DB_2.I am try to use a nickname for it.But nickname creation is not possible until federated server is made.Please tell me how to create a federated server.Moreover, is there any thing extra which I need to buy for this?When I gave this command to create a server CREATE SERVER "TEST1" TYPE DB2/UDB VERSION 8.1
0
2902
by: imusion | last post by:
Hi, I have 2 servers each running AIX and both have a DB2 database setup on them. I'm building a news management application and in our setup we need to have a staging and production setup. So the staging database gets the changes performed and then once we're satisfied with how it looks, we push the changes through SQL queries which perform the (deletions, updating, and inserting of articles) onto the production database by comparing it to...
0
8946
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
9449
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
9310
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...
0
9182
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
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...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3261
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
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.