If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > SQL Query crashes DB

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-27-04, 22:24
rageous rageous is offline
Registered User
 
Join Date: Apr 2004
Posts: 9
SQL Query crashes DB

I have a query like this constructed in Java. I am qurying a table called MetaTable which has columns as TABLE_NAME, START_INDEX, END_INDEX, LOOKUP_TABLENAME. I am basically doing this to get the list of tables within a specific time gap.
This causes my DB to hang. I have run longer and more complicated queries and dont know why this is causing it to crash.


String query = "select LOOKUP_TABLENAME from MetaTable where TABLE_NAME = '" + tableName + "' and
(
(START_INDEX >= sIndex and START_INDEX <= eIndex and (END_INDEX >= eIndex or END_INDEX = -1)) OR
(START_INDEX <= sIndex and END_INDEX >= sIndex and (END_INDEX <= eIndex or END_INDEX = -1)) OR
(START_INDEX <= sIndex and (END_INDEX >= eIndex or END_INDEX = -1)) OR
(START_INDEX >= sIndex and (END_INDEX <= eIndex or END_INDEX = -1))
)";
Reply With Quote
  #2 (permalink)  
Old 05-03-04, 16:34
joebednarz joebednarz is offline
Registered User
 
Join Date: Dec 2003
Location: Oklahoma, USA
Posts: 354
A couple of suggestions:

1) Try removing all WHERE conditions and then test each one by applying only one at a time.

2) Add some indexes, particularly on the START_INDEX and the END_INDEX columns. Create two indexes, not a composite...

JoeB
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On