MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how to know the # of lines not using count(*)

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
jctgf
Beginner


Joined: 05 Nov 2006
Posts: 89
Topics: 36

PostPosted: Sat Jul 28, 2007 9:22 am    Post subject: how to know the # of lines not using count(*) Reply with quote

hi,

I need to know the number of lines in a table right before initiating my processing.

The problem is that the table is extremely large and contains more than 2 billion lines, in average.

If I issue a "select count(*)", it will take me precious 20 minutes or so to get it done (I have simulated it already...).

Is there a way (a SYSIBM control table maybe...) to obtain the actual number of lines of a given table without issuing a "select count(*)" on it?

thanks,
jc
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Sat Jul 28, 2007 9:54 am    Post subject: Reply with quote

jctgf,

If your shop updates the table statistics then you can use the CARDF column in sysibm.systables which contains the total number rows in a table.

check this link for exaplanation of columns in sysibm.systables

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNSQJ12/F.74?DT=20050325102208

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CICS Guy
Intermediate


Joined: 30 Apr 2007
Posts: 292
Topics: 3

PostPosted: Sat Jul 28, 2007 10:31 am    Post subject: Reply with quote

kolusu wrote:
If your shop updates the table statistics then you can use the CARDF column in sysibm.systables which contains the total number rows in a table.
This should be checked, stats can be artificially modified to tweak the way DB2 accesses the database.
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Sat Jul 28, 2007 12:22 pm    Post subject: Reply with quote

jctgf,

I was just wondering, why do you need to know the row count?
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
videlord
Beginner


Joined: 09 Dec 2004
Posts: 147
Topics: 19

PostPosted: Sat Jul 28, 2007 5:03 pm    Post subject: Reply with quote

1. after runstats, you can query cardf from catalog table get the number when runstats running
2. if your site enable RTS, query sysibm.tablespacestats, you can get the number by partition level.
Back to top
View user's profile Send private message
jctgf
Beginner


Joined: 05 Nov 2006
Posts: 89
Topics: 36

PostPosted: Sun Jul 29, 2007 9:31 am    Post subject: Reply with quote

actually i need the number of records in every partition of the table (it's a partitioned table).

the best way would be querying sysibm.tablspacestats, ok?

thanks,
jc
Back to top
View user's profile Send private message Send e-mail
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Mon Aug 06, 2007 8:15 am    Post subject: Reply with quote

jctgf,

I was just wondering, why do you need to know the row count?
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
jctgf
Beginner


Joined: 05 Nov 2006
Posts: 89
Topics: 36

PostPosted: Mon Aug 06, 2007 5:21 pm    Post subject: Reply with quote

it's a partitioned table and i want to place the record in the partition where there is free space
by knowing the number of records in each partition i may assign the correct value to my partition# column (my clustered column)
regards
Back to top
View user's profile Send private message Send e-mail
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Tue Aug 07, 2007 1:32 am    Post subject: Reply with quote

jctgf,
thx for getting back.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Tue Aug 07, 2007 4:14 am    Post subject: Reply with quote

jctgf,
is this a batch or on-line application?

if on-line, what kind of insert volume do you have?
if on-line, does it run 24/7?
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
jctgf
Beginner


Joined: 05 Nov 2006
Posts: 89
Topics: 36

PostPosted: Tue Aug 07, 2007 6:02 pm    Post subject: Reply with quote

It
Back to top
View user's profile Send private message Send e-mail
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Tue Aug 07, 2007 11:09 pm    Post subject: Reply with quote

jctgf,
thx for the info and good luck. sounds like a very intensive (and stressful) process.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
videlord
Beginner


Joined: 09 Dec 2004
Posts: 147
Topics: 19

PostPosted: Thu Aug 09, 2007 9:24 pm    Post subject: Reply with quote

recommendation:
Set up your system enable Real-Time Statistics.
Then you can query SYSIBM.TABLESPACESTATS to get the current row# of each partition
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group