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 > Full tablescan

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-15-04, 07:56
dr_suresh20 dr_suresh20 is offline
Registered User
 
Join Date: Sep 2003
Posts: 218
Full tablescan

I am running db2 v8.1.6.664 on win2k.

I have a generic question.
We have a Data warehouse db and queries are taking some time. I did a explain plan, reorgchk/reorg and runstats, bind etc but the issue seem to be with tablescan where most of the time gets spent. This in turn impact resource utilization eg: CPU, disk sorts etc

btw, summary table/materialized view is not an option since most of the queries are generated at runtime through external application...

Are there any specific ways in which one can avoid full tablescans?

Any thoughts/ideas appreciated.

TIA.
Reply With Quote
  #2 (permalink)  
Old 12-15-04, 08:03
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Yes. Indexes. For example, if most of your queries involve a date range, then it is a very good idea to put an index on the date column. Version 8.1 as the "Design Advisor" to help in this area.

HTH

Andy
Reply With Quote
  #3 (permalink)  
Old 12-15-04, 09:13
dr_suresh20 dr_suresh20 is offline
Registered User
 
Join Date: Sep 2003
Posts: 218
thanks! for your response.

I have tried design advisor and that does not seem to suggest index creation which would reduce time nor avoid ts...

I am doing a sum(.....) in my query therefore assuming that this will go through each and every record in the table. TS relates in high % of sorts (inspite of increasing SORTHEAP and SHEAPTHRES parameters....)

I am still not sure how to go about this?
Reply With Quote
  #4 (permalink)  
Old 12-15-04, 09:16
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
If you are on a Datawarehouse, many of your sorts tend to overflow ... You should consider tuning I/O, like placement of tempspace containers, bufferpools etc.

MQTs may still be an option if your queries(though user generated on the fly) use a similar predicates, summarization etc.

HTH

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #5 (permalink)  
Old 12-15-04, 09:28
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
There are two things that greatly affect whether a tablescan will be used instead of an index scan. The WHERE clause and the ORDER BY clause.
Examine these, mostly the WHERE clause. Some predicates in the WHERE clause can cause a tablescan even if some of them refer to indexed columns. Best rule of thumb here is to keep the predicates simple and not to use functions here.

Andy
Reply With Quote
  #6 (permalink)  
Old 12-16-04, 22:06
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
If DB2 needs to read all the pages in the tablespace, then it will do a tablespace scan because that is the fastest way to do it. If you post the DDL and SQL, then maybe someone can verify that a tablespace is needed.

Even if you have a tablespace scan, there are ways to speed it up, such using the correct extent size, prefetch size, proper number and placement of containers, and proper settings to invoke intra-partition parallelism. How well these things will work depends somewhat on your disk subsystem and how many seperate disks (or arrays) you are able to use for the tablespace.
__________________
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
  #7 (permalink)  
Old 12-17-04, 10:00
dr_suresh20 dr_suresh20 is offline
Registered User
 
Join Date: Sep 2003
Posts: 218
Thanks for all the suggestions..

Let me work on these input to see if we can avoid TS...

Regards.
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