Solved

Query executes forever

Posted on 2013-01-25
7
488 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 143

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 143

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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. …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

821 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