 |
IDS Forum
RE: Tablespace Allocation versus Storage Needs (More Scripting [9 [985]
Posted By: Date:
George is right....TRUNC....
I didn't look at the script(s)...keep in mind that rows larger than a page will have 4 bytes for it's slot table entry, a 4-byte forward pointer on the home page, and slot table entry of 4 bytes on the remainder page. If a row spans multiple pages, then this will repeat.
HTH - Mark.
Mark Scranton Principal Consultant/Teacher IBM Denver
IBM Software Group - Data Management Office: 303-773-5067 Cell: 303-929-0914 email: mscranto@us.ibm.com
"Palmer, George" <George.Palmer@pe To: ids@iiug.org gs.com> cc: Sent by: Subject: RE: Tablespace Allocation versus Storage Needs (More Scripting [9 [985] forum.subscriber@ iiug.org 04/24/2003 10:23 AM
A few notes. I have not looked into the script carfully because of more pressing problems locally
Rows per page needs to use TRUC around ( pagesize - overhead / rowsize + size of slot (4) ) I did not read cafully but did you account for slot table entry in all places.
You do not mention what release of Informix, In Non Fragmented table in release 7, Indexes are inside the table by default not detached ( could this be a problem for you ? )
George
-----Original Message----- From: bill.robert.... [mailto:bill.roberts@verizon.com] Sent: Thursday, April 24, 2003 8:24 AM To: ids@iiug.org Subject: Tablespace Allocation versus Storage Needs (More Scripting [984]
IDS 7.31FD4X2 SunOS 5.7
Okay team, here's one for you:
This copy of the e-mail actually tells you what the problem is...apolog= ies for the previous omission.
I have written a script that is supposed to report space allocation for=
table and table-fragment tablespaces. I am receiving some erroneous res= ults and I have not been able to pinpoint the error in my logic. Please take= a look and see what you can see?I know I am receiving flawed results for = 52 of 2071 tables, but we all know what that means?
The problem: Some tables report that the amount of space I calculate is=
needed to store the actual number of rows in the table is greater than = the amount of space I calculate to be allocated to that table's tablespace.=
Update stats is not an issue.
The eventual goal is to report tables that are allocated beyond their needs. Such tables would be marked for analysis as candidates for rebui= ld to free space within a dbspace. If you know a better way, I am open to suggestion (but likely to continue trudging the path to my destiny with= in the SMI tables...).
Note that this is a first run through and I am aware that there are oth= er considerations when it comes to storage so feel free to mention what yo= u know. You can leave out the varchar part though; rowsize is the max possible size for a row (as far as I can determine) and that will err i= n my favor...
The logic I am using to calculate the space needed to hold the rows tha= t exist within a table is:
the number of rows that fit on a page is calculated with this formula:=
('pagesize less overhead' / rowsize)
The pages required to store those rows is calculated with this formula= : ('number of rows in the table' / 'number of rows that fit on a page')
The KB required to store those rows is calculated with this formula: ('number of pages to store rows * 'O/S page size')
(See attached file: 4iiug.tar)
Regards, Bill Roberts
AAIS Core Production Support, Informix DBA Verizon Data Services Office : (813) 978-2340 Pager: (888) 423-6604 e-mail:bill.roberts@verizon.com
http://dbaman.tmtrfl.tel.gte.com/browser.cgi
#!/bin/ksh #set -x #######################################################################= ######### # Place your very own environmental script here... #######################################################################= ######### . /opt/informix/dba.env.sh
#######################################################################= ######### # Calculate the pagesize less overhead for my O/S. #######################################################################= ######### PAGE_SIZE=3D$(onstat -b | grep buffer | awk {'print $10'}) PAGE_SIZE_LO=3D$(expr $(onstat -b | grep buffer | awk {'print $10'}) - = 24)
#######################################################################= ######### # Create a list of databases in an instance. #######################################################################= ######### for DB in $(printf "output to pipe cat without headings select name fro= m \ sysdatabases where name not in ('onpload','sysmaster','sysutils');" \ | dbaccess 2>/dev/null sysmaster);do
#######################################################################= ######### # Check for connect permission. #######################################################################= ######### echo | dbaccess > /dev/null 2>&1 ${DB} RC=3D$? if [ ${RC} -ne 0 ];then echo "No connect permission to ${DB}" else
#######################################################################= ######### # Check for logging and set isolation level if it is on. #######################################################################= ######### IS_LOGGED=3D$(printf "output to pipe cat without headings \ select is_logging from \ sysdatabases where name =3D \"${DB}\";" \ | dbaccess 2>/dev/null sysmaster | tr -d [:space:]) if [ ${IS_LOGGED} -eq 0 ];then SET_ISOLATION_LEVEL=3D else SET_ISOLATION_LEVEL=3D'set isolation dirty read;' fi #######################################################################= ######### # Create a cross-reference for tables/dbspaces. Remove a lot of junk fr= om the # select once the bugs are fixed... # Oh, and by the way: # # the number of rows that fit on a page is calculated with this formula= : # ('pagesize less overhead' / rowsize) # # The pages required to store those rows is calculated with this formul= a: # ('number of rows in the table' / 'number of rows that fit on a page')=
# # The KB required to store those rows is calculated with this formula: # ('number of pages to store rows * 'O/S page size' # # Note that this is a first run through and I am aware that there are o= ther # considerations when it comes to storage (varchar overhead comes to mi= nd), but # I'll work these issues out later (feel free to mention it though...) #######################################################################= ######### UNL_FILE=3D${DB}_t2d.unl TXT_FILE=3D${DB}_t2d.txt printf "${SET_ISOLATION_LEVEL} UNLOAD TO ${UNL_FILE} delimiter \" \" SELECT UNIQUE partnum, name, tabname, tabtype, rowsize, nrows, (ROUND((nrows*rowsize)/1024)) ROWS_KB, (ROUND(nrows/(${PAGE_SIZE_LO}/rowsize)) *${PAGE_SIZE}) KB_4_ROWS, (SUM(te_size)*${PAGE_SIZE}) EXTENTS_KB, (ROUND((nrows*rowsize)/1024)/(SUM(te_size) *${PAGE_SIZE})*100) PERCENT_ROWS FROM systables t, sysmaster:sysdbspaces s, sysmaster:systabextents e WHERE t.tabid > 99 and t.tabtype =3D \"T\" and t.partnum !=3D 0 and s.dbsnum =3D trunc(t.partnum / 1048576) and t.partnum =3D e.te_partnum GROUP BY 1,2,3,4,5,6 UNION SELECT UNIQUE partn, name, tabname, fragtype, t.rowsize, f.nrows, (ROUND(f.nrows*(t.rowsize+4)/1024)) USED_KB, (ROUND((f.nrows/${PAGE_SIZE_LO}/(t.rowsize+4))=
*${PAGE_SIZE})) KB_4_ROWS, (SUM(te_size)*${PAGE_SIZE}) ALLOCATED_KB, (ROUND((f.nrows*(t.rowsize+4)/1024)/(SUM(te_si= ze) *${PAGE_SIZE}))*100) PERCENT_ROWS FROM systables t, sysfragments f, sysmaster:sysdbspaces s, sysmaster:systabextents e WHERE t.tabid =3D f.tabid and f.fragtype =3D \"T\" and s.dbsnum =3D trunc(f.partn / 1048576) and f.partn =3D e.te_partnum GROUP BY 1,2,3,4,5,6 ORDER BY 3,2;" | dbaccess 2>/dev/null ${DB}
#######################################################################= ######### # Create a few integer variables... #######################################################################= ######### typeset -i PARTN=3D0 typeset -i NROWS=3D0 typeset -i ROWSIZE=3D0 typeset -i USED_KB=3D0 typeset -i KB_4_ROWS=3D0 typeset -i ALLOC_KB=3D0 typeset -i PERCENT_ROWS=3D0
#######################################################################= ######### # Print a heading. #######################################################################= ######### printf "%-9s %-18s %-18s %4s %9s %9s %7s s s %5s\n" \ PARTN DBS TAB TYPE ROWSIZE NROWS USED_KB KB_4_ROWS ALLOC_KB PERCENT_R= OWS > ${TXT_FILE} > ${TXT_FILE}
#######################################################################= ######### # Just an echo so that when I hit an error, I know for which file the e= rror # occurred. Take it out later... #######################################################################= ######### echo "${UNL_FILE}"
#######################################################################= ######### # Create a report. #######################################################################= ######### cat ${UNL_FILE} | while read PARTN NAME TAB TYPE ROWSIZE NROWS USED_K= B KB_4_ROWS ALLOC_KB PERCENT_ROWS;do printf "%-9d %-18s %-18s %4s } .0f d .2f\n" \ ${PARTN} ${NAME} ${TAB} ${TYPE} ${ROWSIZE} ${NROWS} ${USED_KB} ${KB_4_ROWS} ${ALLOC_KB} ${PERCENT_ROWS} >> ${TXT_FILE} done rm ${UNL_FILE} fi done
#######################################################################= ######### # Run a script to report the tables that appear to require a greater allocation # of space than is actually allocated. #######################################################################= ######### echo "Bad Logic nunning now" t2d_badlogic.ksh > t2d_badlogic.txt echo "Bad Logic complete"
=
Messages In This Thread
- Level 0 restore
Scott O'Rourke -- Thursday, 16 January 2003, at 5:36 a.m.
- RE: Level 0 restore
Simmons, Keith -- Thursday, 16 January 2003, at 7:02 a.m.
- Antw: Level 0 restore
Andreas.KUTSCHE@spar.at -- Thursday, 16 January 2003, at 7:24 a.m.
- Re: Antw: Level 0 restore
Scott O'Rourke -- Thursday, 16 January 2003, at 7:42 a.m.
- Re: Level 0 restore
ART KAGEL, BLOOMBERG/ 65E 55TH -- Thursday, 16 January 2003, at 8:39 a.m.
- RE: Tablespace Allocation versus Storage Needs (More Scripting [9 [985]
Mark Scranton -- Monday, 28 April 2003, at 8:22 a.m.
IDS Forum is maintained by Administrator with WebBBS 5.12.
|
 |