View previous topic :: View next topic |
Author |
Message |
SMS Beginner
Joined: 16 Oct 2005 Posts: 53 Topics: 24
|
Posted: Fri Sep 14, 2007 2:23 pm Post subject: Record count in each partition |
|
|
Hi,
I am trying to get the record count in each partition for a 50 part table using the below Unload card. But it returns the record count for the whole table space.
UNLOAD TABLESPACE TT01001D.FS00310T PART(90)
LOCK NO
SELECT 'PARTITION 90- ' || DIGITS(COUNT(*)) FROM DB1.INVENTRY
Since the runstats is not running regulary I cannot take it from TABLESPACESTATS or SYSTABLEPART tables.
Do I need to change anything in the unload card ? Any suggestions please ? _________________ Regards,
SMS |
|
Back to top |
|
|
jsharon1248 Intermediate
Joined: 08 Aug 2007 Posts: 291 Topics: 2 Location: Chicago
|
Posted: Mon Sep 17, 2007 9:15 am Post subject: |
|
|
You can use LISTDEF and TEMPLATE along with UNLOAD to create a separate file for each partition. Here's an example:
Code: |
LISTDEF UNLDLIST
INCLUDE TABLESPACE DB001.TS001 PARTLEVEL
TEMPLATE UNLDDS DSN TESTQUAL.&JO..&SS..&DB..&TS..P&PA.
UNIT DISK DISP (NEW,CATLG,DELETE) SPACE (25,5) MB
TEMPLATE PUNCHDS DSN TESTQUAL.&JO..&SS..&DB..&TS..LOADCRDS
UNIT DISK DISP (NEW,CATLG,DELETE) SPACE (1,1) CYL
UNLOAD LIST UNLDLIST PUNCHDDN PUNCHDS UNLDDN UNLDDS
SHRLEVEL CHANGE ISOLATION UR NOPAD
|
Check the TEMPLATE command in the Utilities manual for a description of all the symbolic parms available. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Mon Sep 17, 2007 9:52 am Post subject: |
|
|
SMS,
You can also isse the partition limit key(defined at the time of the table creation) and do a count(*) with the that key.
ex:
Code: |
PART 1 VALUES ('xxxxxx' )
PART 2 VALUES ('yyyyyyy' )
PART 3 VALUES ('zzzzzzzz' )
|
Code: |
Select count(*) from table where pk_key <= part1 value;
Select count(*) from table where pk_key > part1 value and pk_key <= part2 value;
..
|
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
showkath Beginner
Joined: 23 Mar 2005 Posts: 17 Topics: 7
|
Posted: Mon Sep 17, 2007 11:55 am Post subject: |
|
|
Hi Kolusu,
Thanks for your suggestion.
Actually it's a 100 part table and it has two partition keys. so I have to write 100 Select queries to get the record count based on the partition range. I thought of looking for a simple solution than this.
Jsharon,
Thanks. As part of table space expansion we are dropping a table space and re-creating it. As part of verification, after unloading the data from the production before dropping the TS, we plan to take the record count in each partition to compare it finally. For unloading the data, the unload jobs are already built which will unload in separate files.
For taking the record count, I heard that, using UNLOAD job, we can get the record count based on the partition number without using the partition keys. So I am experimenting on the same.
Please let know whether it's possible to get like that.
Thanks & Regards,
SMS |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Mon Sep 17, 2007 12:00 pm Post subject: |
|
|
Quote: |
I thought of looking for a simple solution than this.
|
The easiest and the best solution is run a REORG and it will update the table stats
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
|
|