Solved

Query executes forever

Posted on 2013-01-25
7
484 Views
Last Modified: 2013-01-25
Hi all,

This gets stuck:

SELECT LATCHSTATUS FROM
      DBO.POSITION WHERE MJID = 3199 FETCH FIRST 1 ROWS ONLY      

If I change the number of rows, it returns instantly (there are no results).

Why? What am I doing wrong?

Any help is appreciated
0
Comment
Question by:darrgyas
  • 3
  • 2
  • 2
7 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 38818326
would adding the following help your query:
OPTIMIZE FOR 1 ROW
0
 
LVL 37

Accepted Solution

by:
momi_sabag earned 250 total points
ID: 38818372
FETCH FIRST 1 ROWS ONLY       implies OPTIMIZE FOR 1 ROW
this looks like some sort of a bug
i would try to run a reorg on the table and all the indexes and see if it solves it
0
 

Author Comment

by:darrgyas
ID: 38818476
adding OPTIMIZE FOR 1 ROW did not change anything.

Can't run reorg - there's no scheduled downtime for the table at all, it is being continuously written to.

Anything else I can try?
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 250 total points
ID: 38818495
as momi_sabag indicated, this may be some bug you hit, at least that is what I saw on some forums searching for this error/problem.
if you don't see any difference in the explain plan, try FIRST 2 ROWS if that gives the same issue.
can you add a ORDER BY to the query?
what version are you using?
0
 

Author Comment

by:darrgyas
ID: 38818514
As I stated in the question, changing the # of rows gets rid of the problem, the statement executed in under a second.

 ORDER BY does not change anything.
0
 

Author Comment

by:darrgyas
ID: 38818520
I am using DB2 Express-C 9.74
0
 
LVL 37

Expert Comment

by:momi_sabag
ID: 38818733
then just change to fetch 2 rows
and in your code, only fetch one
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

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…
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

810 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