MySQL Forums
Forum List  »  Optimizer & Parser

Estimating Index Size on Innodb Tables
Posted by: Paulo Victor Maluf Alves
Date: July 26, 2010 01:49PM

Dears,

I want to estimate an index size, based on innodb tables.


For instance:


Employees:
+------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------------+------+-----+---------+-------+
| emp_no | int(11) | NO | PRI | NULL | |
| birth_date | date | NO | | NULL | |
| first_name | varchar(14) | NO | MUL | NULL | |
| last_name | varchar(16) | NO | | NULL | |
| gender | enum('M','F') | NO | | NULL | |
| hire_date | date | NO | | NULL | |
+------------+---------------+------+-----+---------+-------+

select count(1) from employees;
+----------+
| count(1) |
+----------+
| 300024 |
+----------+

I try:

SELECT ROUND(AVG(LENGTH(first_name)),2) FROM employees;
+----------------------------------+
| ROUND(AVG(LENGTH(first_name)),2) |
+----------------------------------+
| 6.22 |
+----------------------------------+

So:
(6.22 * 300024)/1024/1024 = 1.77 MB


Whats wrong?


if I create an index, it is at least 4x greater:


mysql> create index first_idx01 on employees(first_name);

mysql> SELECT ROUND(index_length/1024/1024,2) as total_index_size_mb FROM information_schema.TABLES WHERE table_name = 'employees';
+---------------------+
| total_index_size_mb |
+---------------------+
| 9.52 |
+---------------------+


Thanks.

Options: ReplyQuote


Subject
Views
Written By
Posted
Estimating Index Size on Innodb Tables
11344
July 26, 2010 01:49PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.