Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I estimate the size of an Oracle index?

Tags:

sql

oracle

I'm considering adding an index to an Oracle table, but I'd like to first estimate the size of the index after it has been built (I don't need a precise size - just an estimate.)

Supposing I have access to all of the meta-data about the table (number of rows, columns, column data types, etc) that I can execute any arbitrary Oracle SQL query to get additional data about the current state of the table, and I know what I would want the index definition to be, how can I estimate this size?

like image 983
Jared Avatar asked May 05 '09 22:05

Jared


1 Answers

You can use these Oracle Capacity planning and Sizing Spreadsheets.

For something not quite as full-blown, if you just want back of the envelope type rough estimates for the index:

Calculate the average size of each of the columns that make up the index key and sum the columns plus one rowid and add 2 bytes for the index row header to get the average row size. Now add just a little to the pctfree value for the index to come up with an overhead factor, maybe 1.125 for pctfree of 10.

number of indexed table rows X avg row len X 1.125

Note - if the index contains nullable columns then every table row may not appear in the index. On a single column index where 90% of the columns are null only 10% would go into the index.

Compare estimate to tablespace extent allocation method and adjust final answer if necessary.

Also a larger overhead factor may be better as the index gets bigger since the more data indexed the more branch blocks necessary to support the index structure and the calculation really just figures for leaf blocks.

like image 96
cletus Avatar answered Oct 07 '22 15:10

cletus