dbTalk Databases Forums  

Optimizing Query

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss Optimizing Query in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Erwin
 
Posts: n/a

Default Optimizing Query - 08-13-2003 , 04:42 AM






Can anybody tell me how to improve the performance of this query?

SELECT
NID, LEVEL, VALUE
FROM
DATA
WHERE
DID=2 AND STATUS=0

The value of STATUS is either 0 or 1. The primary key of DATA is EID
which I don't use in the query.

The total cost of the query without index is 240.47
If I put index on DID and STATUS, the total cost is 190.47.

Thanks

Erwin

Reply With Quote
  #2  
Old   
Joerg Ammann
 
Posts: n/a

Default Re: Optimizing Query - 08-13-2003 , 08:07 AM






erwin2 (AT) myrealbox (DOT) com (Erwin) wrote in message news:<43ecf6d7.0308130142.3091870d (AT) posting (DOT) google.com>...
Quote:
Can anybody tell me how to improve the performance of this query?

SELECT
NID, LEVEL, VALUE
FROM
DATA
WHERE
DID=2 AND STATUS=0

The value of STATUS is either 0 or 1. The primary key of DATA is EID
which I don't use in the query.

The total cost of the query without index is 240.47
If I put index on DID and STATUS, the total cost is 190.47.

Thanks

Erwin
datatype of STATUS ?
did you a
runstats WITH DISTRIBUTION
on the table?, otherwise the optimizer does not know that there are
only 2 different values for STATUS.


Reply With Quote
  #3  
Old   
Erwin
 
Posts: n/a

Default Re: Optimizing Query - 08-13-2003 , 10:07 PM



Quote:
datatype of STATUS ?
I use SMALLINT. Actually, I need only two values for STATUS.

Quote:
did you a
runstats WITH DISTRIBUTION
on the table?, otherwise the optimizer does not know that there are
only 2 different values for STATUS.
I didn't execute RUNSTATS WITH DISTRIBUTION on the table. I try to
execute RUNSTATS WITH DISTRIBUTION, and it works.

Thanks


Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.