473,834 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Table size and index size

I am trying to write a sql script to estimate size and count of rows of
all tables and indexes within a schema.

Here's what I have so far but need a little help.

#$1 is database name and $2 is schema name
db2 connect to $1
db2 select tabname,t1.fpag es * t2.pagesize as bytes from syscat.tables
t1, syscat.tablespa ces t2 where t1.tabschema='$ 2' and
t1.tbspace=t2.t bspace
How can I add the index_size for each index under a table?
#syscat.indexes lists nleafs but it doesn't compute.
How can I list the number of rows for each table as I progress through
the query.

Nov 12 '05 #1
3 24208
Since you select t1.fpages, it seems to me you rely on your statistics to be
current.
Given that, t1.card will give you the number of rows in the table.

However, t1.fpages will always include the count of empty pages, so
fpages*pagesize as bytes may never reflect reality.
The same applies to indexes. nleafs indicate the number of pages in the
last level. They are pages holding keys and rids. Some may be full, some
may be empty. It does not count the space that other nodes occupy.
HTH, Pierre.

--
Pierre Saint-Jacques
SES Consultants Inc.
514-737-4515
"dunleav1" <jm*@dunleavyen terprises.com> a écrit dans le message de
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
I am trying to write a sql script to estimate size and count of rows of
all tables and indexes within a schema.

Here's what I have so far but need a little help.

#$1 is database name and $2 is schema name
db2 connect to $1
db2 select tabname,t1.fpag es * t2.pagesize as bytes from syscat.tables
t1, syscat.tablespa ces t2 where t1.tabschema='$ 2' and
t1.tbspace=t2.t bspace
How can I add the index_size for each index under a table?
#syscat.indexes lists nleafs but it doesn't compute.
How can I list the number of rows for each table as I progress through
the query.


Nov 12 '05 #2
Yes, I am relying on my statistics to be current.
Thanks for card definition to equal the number of rows.
Since fpages may by 0, what is the best way to calculate the size for
the table and index?

Nov 12 '05 #3
If you look at your docs., you'll find that table stats. include
FPAGES: Total number of pages to hold the table
NPAGES: Number of page holding at least one row.
The ratio of npages over fpages is an indication of the amount of "fluff" in
your table.
If FPAGES is 0 then CARD should be 0 also.

You can use Google to find stuff like that. I did a google search on: db2
size estimate.
HTH, Pierre.
Here's what Craig Tobias from IBM suggests;
estimate size
Posted by: Craig Tobias, 2004 March 29 02:21 PM

Jean-Marc,

In v8.1, we created some stored procedures to capture and save storage
snapshots. Snapshots can be captured for Databases, Table spaces,
Tables,
Indexes, and Database Partition Groups. To capture storage data
(including
estimated size) for all objects (including tables) in a database, you
should
capture a database snapshot.

Before capturing a snapshot, you must create the storage management
tables
(where all snapshot data is stored). Run the following command to
create the
storage tables, and specify a table space for the tables.

db2 connect to
db2 call create_storagem gmt_tables('')

Now, capture a snapshot at the database level... this can take a while
for
large databases. You may also want to update your table statistics
using
the Runstats utility before running the storage snapshot. To capture a
snapshot, run the following command:

db2 call capture_storage mgmt_info(0, ' ', '')

The table related data is stored in the SYSTOOLS.STMG_T ABLE table. You
also
need to do a name lookup in the SYSTOOLS.STMG_O BJECT table. To query
the
storage management tables for estimated table size, run the following
command...

SELECT
MAX(tables.STMG _TIMESTAMP) as SNAPSHOT_TIMEST AMP,
tables.OBJ_ID,
object.OBJ_NAME ,
object.obj_sche ma,
tables.ESTIMATE D_SIZE
FROM
SYSTOOLS.STMG_T ABLE tables
INNER JOIN
SYSTOOLS.STMG_O BJECT object
ON tables.obj_id = object.obj_id AND tables.stmg_tim estamp =
object.stmg_tim estamp
GROUP BY tables.STMG_TIM ESTAMP, tables.ESTIMATE D_SIZE, tables.obj_id,
object.obj_name , object.obj_sche ma
The number of bytes used by the table is displayed in the
ESTIMATED_SIZE
column.

You can also delete historical snapshots by deleting entries from the
SYSTOOLS.STMG_R OOT_OBJECT table. To delete all historical data, run
the
following query:

DELETE FROM SYSTOOLS.STMG_R OOT_OBJECT

There is also a stored procedure which will drop all of the storage
management tables.

db2 call drop_storagemgm t_tables(0)
All of the snapshot data can easily be viewed using the storage
management
tool which is launched from the DB2 Control Center, Database > Manage
Storage...

The storage management tool provides detailed historical analysis of
the
captured snapshot data for all storage related objects in the
database, as
well as a way to schedule regular snapshots, and delete historical
snapshots.

Craig Tobias
DB2 Admin. Tools Development
IBM Toronto Lab

--
Pierre Saint-Jacques
SES Consultants Inc.
514-737-4515
"dunleav1" <jm*@dunleavyen terprises.com> a écrit dans le message de
news:11******** ************@f1 4g2000cwb.googl egroups.com...
Yes, I am relying on my statistics to be current.
Thanks for card definition to equal the number of rows.
Since fpages may by 0, what is the best way to calculate the size for
the table and index?


Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1483
by: jgb_dba | last post by:
Hello, I not exactly sure how to determine the table when given the following information: -- Could not find the index for RID '999999' in index page ('1:99999999'), index id ), database (whatever). --
11
9493
by: SarahMarsden | last post by:
I'm new to Dreamweaver (using MX 2004). I have a 2 row 3 column table. I have set each column to 200 pixels. The second row I have merged into one cell. When I enter text (or anything else) into the merged cell the 3 columns above change pixel width. The pixel width still says 200. But the pixel width shown in green above the columns it says 200(172)for example. It seems that the bracketed number is the size the cell displays at rather...
2
10268
by: Stanley Sinclair | last post by:
About to create a table which will "include" a BLOB. Am not sure how large to make the container and the tablespace. What I see says that BLOB is stored "separately." However, I don't know where. With a table kinda like: CREATE TABLE BLOB_TABLE ( BLOB_ID INT,
1
4927
by: stabbert | last post by:
We are on DB2 UDB 8.2.2 on AIX. I know this question has been asked many times on the ng but I am just not finding a real good answer. I need to be able to not only determine existing table data size and index size but also estimate for the future. I keep seeing info regarding using reorgchk and the such however my dba will not allow us developers to have access to the comands necessary such as runstats. How can a lowely developer such...
1
5235
by: db2udbgirl | last post by:
Env : DB2 UDB 8.2 / AIX 5.3 When I try to use some DB2 Utilities against a partitioned table which is not defined on a particular node (Node 0 in this case) I'm getting this error. /home/db2udbgirl> db2 load query table ETL.TRANSACTION SQL6024E Table or index "TRANSACTION" is not defined on node "0". Hence I would do the following operation as a workaround
4
5182
by: Suresh.Eddala | last post by:
Hi, I am trying to get file size information in my code. FileInfo().Length is returning the size of the file. I have checked on File information in windows right click properties, it has two properties. -- Size -- Size on disk
7
10061
by: xformer | last post by:
Hello everybody, today I was working on a web site when I found a strange effect. Take the following html document: ----begin---- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html;
2
2501
by: BD | last post by:
Hi, all. My background is more Oracle than db2. My skills at SQL tuning are quite limited. I'm running 8.2 on Windows. I'm tasked with some SQL optimization, and am doing some explain plans on various queries.
6
8080
by: shawno | last post by:
Hi, We're running DB2 v8.1 on a windows platform and have a database that is quite large. It basically contains one table with a BLOB field (each blob is a zip file, maybe 500K to 1MB), and this particular table is close to 300GB in size. We are not experiencing any problems, and there is plenty of space on the server, but I was just wondering if there is limit in DB2 to how big this table can get. We are guessing it is going to...
0
9800
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9651
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9340
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7763
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5630
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5802
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3987
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3085
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.