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 > Query optimization ..

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-25-10, 12:51
sokando sokando is offline
Registered User
 
Join Date: Feb 2010
Posts: 4
Query optimization ..

may someone help me with this ?! ...
i want to know how can i calculate the cost for processing a query ..
i mean how can i calculate the number of disc accesses to process the query ..
in order to optimize the query processing ... thanks
Reply With Quote
  #2 (permalink)  
Old 02-25-10, 13:10
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
The [estimated] I/O and CPU load figures can be found in the query explain plan. Use Visual Explain, db2expln or db2exfmt to obtain the plan in readable form.
Reply With Quote
  #3 (permalink)  
Old 02-25-10, 13:10
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
You can do an Explain, which will estimate the cost and number of rows based on the statistics as of the last runstats. You can run the explain via command line, or use the Visual Explain from the Control Center.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #4 (permalink)  
Old 02-25-10, 13:40
sokando sokando is offline
Registered User
 
Join Date: Feb 2010
Posts: 4
i meant it simple ..
an example ...my selection will select 400 records out of 1000 record and then select another 200 records out of 1000 records and cartisian product them (Selection 1 × Selection 2).. and every block carries 4 records (blocking factor = 4 records) .. how many hard accesses then ? ..
Reply With Quote
  #5 (permalink)  
Old 02-25-10, 14:30
dav1mo dav1mo is offline
Registered User
 
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
each time will be different due to what is in bufferpool at the time, so there is never anyway to determine how many times you will actually go to disk. The way to optimize your query is to use visual explain and ensure proper index access with matching columns to all of your tables. Also, stay away from cartesian products.
Dave
Reply With Quote
  #6 (permalink)  
Old 02-25-10, 14:30
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Take a look at the dynamic SQL snapshot:
Code:
 Rows read                          = 23640
 Internal rows updated              = 0
 Rows written                       = 0
 Statement sorts                    = 3
 Statement sort overflows           = 0
 Total sort time                    = 0
 Buffer pool data logical reads     = 192
 Buffer pool data physical reads    = 1
 Buffer pool temporary data logical reads   = 0
 Buffer pool temporary data physical reads  = 0
 Buffer pool index logical reads    = 1
 Buffer pool index physical reads   = 1
 Buffer pool temporary index logical reads  = 0
 Buffer pool temporary index physical reads = 0
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