473,785 Members | 2,498 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

poor select performance

I have 1 table (out of many) that has very poor performance when performing
a select into on. The select statement is called multiple times. We've
found each call to take almost 1 second... we were expecting less than .1
seconds.

The select stmt looks like:

select key,data into key_buff, data_buff from tablename where key > curr_key
AND key < max_key ORDER by key FETCH FIRST 1 ROW ONLY;

Any idea to troubleshoot performance ?

Thanks

Nov 12 '05 #1
10 3983
"AC Slater" <no***@yahoo.co m> wrote in message
news:UK******** ************@ne ws4.srv.hcvlny. cv.net...
I have 1 table (out of many) that has very poor performance when performing a select into on. The select statement is called multiple times. We've
found each call to take almost 1 second... we were expecting less than .1
seconds.

The select stmt looks like:

select key,data into key_buff, data_buff from tablename where key > curr_key AND key < max_key ORDER by key FETCH FIRST 1 ROW ONLY;

Any idea to troubleshoot performance ?

Thanks

Can you please identify the host variables vs. the DB2 columns?
Nov 12 '05 #2

"Mark A" <ma@switchboard .net> wrote in message
news:K_******** *********@news. uswest.net...
"AC Slater" <no***@yahoo.co m> wrote in message
news:UK******** ************@ne ws4.srv.hcvlny. cv.net...
I have 1 table (out of many) that has very poor performance when

performing
a select into on. The select statement is called multiple times. We've
found each call to take almost 1 second... we were expecting less than ..1 seconds.

The select stmt looks like:

select key,data into key_buff, data_buff from tablename where key >

curr_key
AND key < max_key ORDER by key FETCH FIRST 1 ROW ONLY;

Any idea to troubleshoot performance ?

Thanks

Can you please identify the host variables vs. the DB2 columns?


key and data are the only table columns. The rest are stored procedure
params.

/Frank

Nov 12 '05 #3
> > > I have 1 table (out of many) that has very poor performance when
performing
a select into on. The select statement is called multiple times. We've found each call to take almost 1 second... we were expecting less than .1 seconds.

The select stmt looks like:

select key,data into key_buff, data_buff from tablename where key >

curr_key
AND key < max_key ORDER by key FETCH FIRST 1 ROW ONLY;

Any idea to troubleshoot performance ?

Thanks

Can you please identify the host variables vs. the DB2 columns?


key and data are the only table columns. The rest are stored procedure
params.

/Frank

1. Is there an index on key?
2. Have you executed the runstats command on the table and indexes? You must
rebind after runstats is performed.
2. How many rows are in the answer set without the fetch first row only?
3. I would use "where key between curr_key and key_max" although it might
not make any difference depending on which query optimization level is used.
Nov 12 '05 #4

"Mark A" <ma@switchboard .net> wrote in message
news:3N******** *********@news. uswest.net...
> I have 1 table (out of many) that has very poor performance when
performing
> a select into on. The select statement is called multiple times. We've > found each call to take almost 1 second... we were expecting less
than .1
> seconds.
>
> The select stmt looks like:
>
> select key,data into key_buff, data_buff from tablename where key >
curr_key
> AND key < max_key ORDER by key FETCH FIRST 1 ROW ONLY;
>
> Any idea to troubleshoot performance ?
>
> Thanks
>
Can you please identify the host variables vs. the DB2 columns?
key and data are the only table columns. The rest are stored procedure
params.

/Frank

1. Is there an index on key?
2. Have you executed the runstats command on the table and indexes? You

must rebind after runstats is performed.
2. How many rows are in the answer set without the fetch first row only?
3. I would use "where key between curr_key and key_max" although it might
not make any difference depending on which query optimization level is used.


Yes there is an index on key.
There will be about 40,000 rows returned...

The same SQL statement is run on a different table (same structure, just
about half the rows). THe same loop (retrieving 20 rows), takes 1.5 seconds
compared to 30 for the 'bad table'. They have the same structure just a
different number of rows (40K vs 15K).

/F
Nov 12 '05 #5
1. Is there an index on key?
2. Have you executed the runstats command on the table and indexes? You

must rebind after runstats is performed.
2. How many rows are in the answer set without the fetch first row only?
3. I would use "where key between curr_key and key_max" although it might
not make any difference depending on which query optimization level is used.


Interesting enough I found the db2expln for this sql statement and the SAME
sql statement on another system where things perform better ,, Now that I
found this info not sure what to do with it:

--Path on bad system--
Section Code Page = 819

Estimated Cost = 104.929337
Estimated Cardinality = 1.000000

Table Constructor
| 1-Row(s)
Residual Predicate(s)
| #Predicates = 1
Nested Loop Join
| Piped Inner
| Access Table Name = PRODPCIA.RIAUDT ID = 16,4
| | #Columns = 0
| | Index Scan: Name = PRODPCIA.AUD01_ RIAUDT_PK ID = 1
| | | Regular Index (Clustered)
| | | Index Columns:
| | | | 1: LFKEY (Ascending)
| | | #Key Columns = 1
| | | | Start Key: Exclusive Value
| | | | | 1: ?
| | | | Stop Key: Inclusive Value
| | | | | 1: ?
| | | Index-Only Access
| | | Index Prefetch: None
| | | Insert Into Sorted Temp Table ID = t1
| | | | #Columns = 1
| | | | #Sort Key Columns = 1
| | | | | Key 1: (Ascending)
| | | | Sortheap Allocation Parameters:
| | | | | #Rows = 76
| | | | | Row Width = 12
| | | | Piped
| | | | Duplicate Elimination
| | Isolation Level: Uncommitted Read
| | Lock Intents
| | | Table: Intent None
| | | Row : None
| Sorted Temp Table Completion ID = t1
| List Prefetch Preparation
| | Access Table Name = PRODPCIA.RIAUDT ID = 16,4
| | | #Columns = 2
| | | Relation Scan
| | | | Prefetch: 10 Pages
| | | Lock Intents
| | | | Table: Intent Share
| | | | Row : Next Key Share
| | | Sargable Predicate(s)
| | | | #Predicates = 2
Insert Into Sorted Temp Table ID = t2
| #Columns = 2
| #Sort Key Columns = 1
| | Key 1: LFKEY (Ascending)
| Sortheap Allocation Parameters:
| | #Rows = 1
| | Row Width = 140
| | Sort Limited To Estimated Row Count
| Piped
Access Temp Table ID = t2
| #Columns = 2
| Single Record
| Relation Scan
| | Prefetch: Eligible
Return Data to Application
| #Columns = 2

End of section
--- On good system --

SQL Statement:

SELECT LFKEY, CDATA INTO :H00004 :H00005 , :H00010 :H00011
FROM RIAUDT
WHERE LFKEY > :H00004 :H00005 AND LFKEY <= :H00012 :H00013
ORDER BY lfkey
FETCH FIRST 1 ROW ONLY
Section Code Page = 819

Estimated Cost = 0.161109
Estimated Cardinality = 0.000000

Table Constructor
| 1-Row(s)
Residual Predicate(s)
| #Predicates = 1
Nested Loop Join
| Access Table Name = DB2C81.RIAUDT ID = 3,25
| | #Columns = 2
| | Index Scan: Name = DB2C81.RIAUDT_P K ID = 1
| | | Regular Index (Not Clustered)
| | | Index Columns:
| | | | 1: LFKEY (Ascending)
| | | #Key Columns = 1
| | | | Start Key: Exclusive Value
| | | | | 1: ?
| | | | Stop Key: Inclusive Value
| | | | | 1: ?
| | | Data Prefetch: None
| | | Index Prefetch: None
| | Lock Intents
| | | Table: Intent Share
| | | Row : Next Key Share
Return Data to Application
| #Columns = 2

End of section
Nov 12 '05 #6
"AC Slater" <no***@yahoo.co m> wrote in message
news:eh******** *************@n ews4.srv.hcvlny .cv.net...

Interesting enough I found the db2expln for this sql statement and the SAME sql statement on another system where things perform better ,, Now that I
found this info not sure what to do with it:

The first one is creating a temporary table. Looks like it is using UR
isolation level.

Try using CS isolation level (or anything but UR) and add this clause to the
SQL:

optimize for 1 row

This is in addition to the "select 1 row only" clause.
Nov 12 '05 #7

"Mark A" <ma@switchboard .net> wrote in message
news:_u******** *********@news. uswest.net...
"AC Slater" <no***@yahoo.co m> wrote in message
news:eh******** *************@n ews4.srv.hcvlny .cv.net...

Interesting enough I found the db2expln for this sql statement and the SAME
sql statement on another system where things perform better ,, Now that I found this info not sure what to do with it:

The first one is creating a temporary table. Looks like it is using UR
isolation level.

Try using CS isolation level (or anything but UR) and add this clause to

the SQL:

optimize for 1 row

This is in addition to the "select 1 row only" clause.


How do I change the isolation level? I really dont have access to change
the stored procedure as it is performing ok on most DBs. I was/am hoping to
figure out what can be done to the system DB itslef(maybe the isolation
level) or table organization/stats to fix the bad performance.

/F

Nov 12 '05 #8
> How do I change the isolation level? I really dont have access to change
the stored procedure as it is performing ok on most DBs. I was/am hoping to figure out what can be done to the system DB itslef(maybe the isolation
level) or table organization/stats to fix the bad performance.

/F

I am not an expert is stored procedures, but I assume that isolation level
is a bind parameter for the stored procedure. But the problem is that it is
creating a temporary result table and sorting the results and then returning
the first row. If there is an index on the only predicate column (which is
the same column as the order by), I am not sure why it is doing the
temporary table.

Are you sure you gave the actual SQL statement that is being used? Did you
reorg the table, perform runstats, and then rebind?
Nov 12 '05 #9

"Mark A" <ma@switchboard .net> wrote in message
news:Zh******** *********@news. uswest.net...
How do I change the isolation level? I really dont have access to change the stored procedure as it is performing ok on most DBs. I was/am
hoping to
figure out what can be done to the system DB itslef(maybe the isolation
level) or table organization/stats to fix the bad performance.

/F
I am not an expert is stored procedures, but I assume that isolation

level is a bind parameter for the stored procedure. But the problem is that it is creating a temporary result table and sorting the results and then returning the first row. If there is an index on the only predicate column (which is
the same column as the order by), I am not sure why it is doing the
temporary table.

Are you sure you gave the actual SQL statement that is being used? Did you
reorg the table, perform runstats, and then rebind?


As Returned by the db2expln the SQL is:

SELECT LFKEY, CDATA Into :H0004 :H0005, :H00010 :H00011
FROM RITABLE
WHERE LFKEY > :H0004 :H0005 AND LFKEY <= :H00012 :H00013
ORDER BY LFKEY
FETCH FIRST 1 ONLY

That portion of the db2explan is the same on both (the good and bad system).
The access plan below it is what differs.

/Frank

Nov 12 '05 #10

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

Similar topics

1
7413
by: Kevin Frey | last post by:
Hello, I have a test database with table A containing 10,000 rows and a table B containing 100,000 rows. Rows in B are "children" of rows in A - each row in A has 10 related rows in B (ie. B has a foreign key to A). Using ODBC I am executing the following loop 10,000 times, expressed below in pseudo-code: "select * from A order by a_pk option (fast 1)"
18
2378
by: pb648174 | last post by:
Greeting, below is the complete SQL taken from aspfaq.com (retrieved from this newsgroup I believe) The query takes about two minutes to run. Does anybody have a better set based way (sub-second response) to determine business days? CREATE TABLE dbo.Calendar ( dt SMALLDATETIME NOT NULL PRIMARY KEY
3
5269
by: sac | last post by:
I am using DB2 v8.1 on UNIX. At times the database shows extremely poor performance. I do not have dba/admin rights nor do I have the web based client for db2 v8.1. I have only command line access. Also DBA support starts after our jobs have completed. (1) Is there any command that I could use from command line to find out the process taking up maximum of the database resources ? (2) Can the database snapshot be used for this purpose ?...
3
1100
by: melvers | last post by:
I have a C# application that compiles other C# functions on-the-fly depending on user selections. There are several C# functions that can be selected. There is one that takes considerably longer than the rest. This function seems to have an unusual performance characteristic. If it is the first one selected it takes 7 times longer to run than if it is not the first one selected. In other words if I start the application and select this one...
20
2122
by: John Mark Howell | last post by:
I had a customer call about some C# code they had put together that was handling some large arrays. The performance was rather poor. The C# code runs in about 22 seconds and the equivalent C++.Net code runs in 0.3 seconds. Can someone help me understand why the C# code performance is so poor? I rewote the C# code to use a single dimenional array and the time went down to about 3 seconds, but that's still no explaination as to why the...
4
2689
by: Jim Devenish | last post by:
I have converted an Access back-end to SQL Server back-end but am having some problems. The Access to Access application has been running well for some years. I have successfully copied all the data to SQL Server and linked the tables to the front end .mdb (I am not using .adp). Some queries were performing poorly so I have converted these to Views and linked to them. Everything works well with good response but when about 8-10...
1
3898
by: Billy | last post by:
Hi All, I'm attempting to use the MapNetworkDrive <snippedbelow from entire code below with very poor performance results. Basically, I have very small 73kb text files that are rewritten daily to a network share using the MapNetworkDrive command to connect to the valid \\servername\share path. After successfully connecting the drive in the ASP code, the text file
4
2402
by: joa2212 | last post by:
Hello everybody, I'm posting this message because I'm quiet frustrated. We just bought a software from a small software vendor. In the beginning he hosted our application on a small server at his office. I think it was a Fujitsu-Siemens x86 running debian Linux. The performance of the DSL-Line was very poor, so we decided to buy an own machine to host the application ourselves.
2
4681
by: apollock | last post by:
Our application is having an issue where a query in a stored procedure periodically gets a bad plan with a Lazy Spool Operator that changes the query execution time from 5ms to 900ms and kills our CPU. We are running x64 SQL 2005 SP2 on Windows 2003 SP2. We thought it might be parameter sniffing that was causing the bad plan, so we re-wrote the query to disable parameter sniffing. Unfortunately, that made the problem worse as we always...
0
9645
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
9481
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10341
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
9954
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
6741
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();...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4054
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
3656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
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.