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 > Verification that data in tables exists

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-22-10, 06:20
Bartik Bartik is offline
Registered User
 
Join Date: Nov 2010
Posts: 4
Verification that data in tables exists

Hi,
I have a task to verify that data in tables exists against huge amount of tables (>1000).
This operation should be processed as fast as possible. (Main criteria)
I'm using .Net provider and z/OS v8.

For now I see following decision:
To the server I will send 1 statement that contains several following queries:
SELECT 1 FROM a FETCH FIRST ROW ONLY FOR READ ONLY WITH UR;
SELECT 2 FROM b FETCH FIRST ROW ONLY FOR READ ONLY WITH UR;
....
(To prevent script is too complex error I will split it up by 500)

If you see more productive approaches then you are welcome in this topic.
Thanks in advance.
Reply With Quote
  #2 (permalink)  
Old 12-22-10, 08:23
dav1mo dav1mo is offline
Registered User
 
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
How about read the catalog views and only find tables that are empty?
Dave
Reply With Quote
  #3 (permalink)  
Old 12-22-10, 08:34
Bartik Bartik is offline
Registered User
 
Join Date: Nov 2010
Posts: 4
Catalog views don't have such information.
(Correct me if I'm wrong)
There are info about statistics only but it can be not actual.
Reply With Quote
  #4 (permalink)  
Old 12-22-10, 14:58
schintala schintala is offline
Registered User
 
Join Date: Apr 2005
Location: USA
Posts: 119
I think you can get the table count from catalogs provided if your stats are up to date.
Reply With Quote
  #5 (permalink)  
Old 12-22-10, 15:53
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
If you have statistics collected on the tables, you can query the catalog and find tables without any rows. But you are right that those statistics could be outdated. However, in such a situation you probably have a different problem anyway: if the stats are not up to date, you have a good chance that the optimizer is picking sub-optimal access paths. So it is usually a good idea to make sure the statistics are more or less up to date.

What you could do is this: for all important tables you keep the stats up to date and rely on the stats. For all other tables, you have to query the table itself.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
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