Solved

Query executes forever

Posted on 2013-01-25
7
494 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

628 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