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 > Database Server Software > DB2 > To optimize queries

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-17-09, 06:08
qxz qxz is offline
Registered User
 
Join Date: Apr 2002
Posts: 84
Question To optimize queries

Dear All,

I have the following queries. Is there any way/tool that I can optimize them? Thanks!

1. select distinct P.UNIT_ID, ROW_NUMBER() over (order by PC.POINTS) as RowNumber
from UNIT P, UNIT_INFO PI, UNIT_CONFIG PC
where P.UNIT_ID = PC.UNIT_ID and PC.UNIT_ID = PI.UNIT_ID and
PC.VERSION = PI.VERSION
and PC.VERSION = (select max(VERSION) from UNIT_CONFIG where UNIT_ID = PC.UNIT_ID and STATUS = 'approved')
and (PC.OPERATION_TYPE <> 'D' or PC.OPERATION_TYPE is null)
and (PI.COUNTRY = 'IN' and PI.LANG = 'English')
and CURRENT_TIMESTAMP + ((select CT.TIME_OFFSET from COUNTRY CT
WHERE CT.ISO3166_CODE = 'US') hours) between PC.EFF_START_DATE and PC.EFF_END_DATE + 1 days

2. select X.* from (
select P.*, ROW_NUMBER() over (order by P.UNIT_CODE) as RowNumber
from UNIT P, UNIT_CONFIG PC
where P.UNIT_ID = PC.UNIT_ID and PC.VERSION = (select max(VERSION) from UNIT_CONFIG where UNIT_ID = PC.UNIT_ID and status = 'approved') and (PC.OPE_TYPE <> 'D' or PC.OPE_TYPE is null) ) X where RowNumber between 1 and 20
Reply With Quote
  #2 (permalink)  
Old 11-24-09, 14:56
schintala schintala is offline
Registered User
 
Join Date: Apr 2005
Location: USA
Posts: 119
I'll use visual explain tool to see how the query running and accordingly try to optimize. You may also try looking at this tool
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