View previous topic :: View next topic |
Author |
Message |
jctgf Beginner
Joined: 05 Nov 2006 Posts: 89 Topics: 36
|
Posted: Sat Jul 28, 2007 9:22 am Post subject: how to know the # of lines not using count(*) |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
CICS Guy Intermediate
Joined: 30 Apr 2007 Posts: 292 Topics: 3
|
Posted: Sat Jul 28, 2007 10:31 am Post subject: |
|
|
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 |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Sat Jul 28, 2007 12:22 pm Post subject: |
|
|
jctgf,
I was just wondering, why do you need to know the row count? _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
 |
videlord Beginner
Joined: 09 Dec 2004 Posts: 147 Topics: 19
|
Posted: Sat Jul 28, 2007 5:03 pm Post subject: |
|
|
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 |
|
 |
jctgf Beginner
Joined: 05 Nov 2006 Posts: 89 Topics: 36
|
Posted: Sun Jul 29, 2007 9:31 am Post subject: |
|
|
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 |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Mon Aug 06, 2007 8:15 am Post subject: |
|
|
jctgf,
I was just wondering, why do you need to know the row count? _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
 |
jctgf Beginner
Joined: 05 Nov 2006 Posts: 89 Topics: 36
|
Posted: Mon Aug 06, 2007 5:21 pm Post subject: |
|
|
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 |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue Aug 07, 2007 1:32 am Post subject: |
|
|
jctgf,
thx for getting back. _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue Aug 07, 2007 4:14 am Post subject: |
|
|
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 |
|
 |
jctgf Beginner
Joined: 05 Nov 2006 Posts: 89 Topics: 36
|
Posted: Tue Aug 07, 2007 6:02 pm Post subject: |
|
|
It |
|
Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue Aug 07, 2007 11:09 pm Post subject: |
|
|
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 |
|
 |
videlord Beginner
Joined: 09 Dec 2004 Posts: 147 Topics: 19
|
Posted: Thu Aug 09, 2007 9:24 pm Post subject: |
|
|
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 |
|
 |
|
|