3

How do I determine the size of an index in MySQL 5.1?

Ricardo Altamirano
  • 14,650
  • 21
  • 72
  • 105
Rafael
  • 1,061
  • 4
  • 16
  • 32

2 Answers2

5

is this what you need? (from here)

Community
  • 1
  • 1
William
  • 3,511
  • 27
  • 35
  • Yes, it is in bytes. (http://stackoverflow.com/questions/3842086/is-mysql-index-length-in-bytes) – William Nov 02 '10 at 15:28
4

Use INFORMATION_SCHEMA.TABLES

Example : For a table called mydb.mytable, run this query

SELECT index_length NDXSIZE FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema='mydb' AND table_name='mytable';

Answer comes back in bytes. If you want the answer in KB do this:

SELECT index_length/POWER(1024,1) NDXSIZE FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema='mydb' AND table_name='mytable';

For MB, use POWER(1024,2)

For GB, use POWER(1024,3)

etc, etc, ...

RolandoMySQLDBA
  • 43,883
  • 16
  • 91
  • 132
  • @user491757 - welcome to SO. "Signatures" in answers are generally discouraged - people will go look at your profile page if they're interested: http://stackoverflow.com/users/491757/user491757 More details in the FAQ: http://stackoverflow.com/faq – McDowell Oct 29 '10 at 21:25