MYD files size too big even if table is empty


#1

Hi

I have a table called LOGS_2009.
In the directory $MYSQL/myBase i have

-rw-rw---- 1 mysql mysql 8782 oct 4 2008 logs_2009.frm
-rw-rw---- 1 mysql mysql 2137037824 oct 21 2008 logs_2009.MYI
-rw-rw---- 1 mysql mysql 1936289840 oct 21 2008 logs_2009.MYD

i did the following:
mysql> select count(*) from logs_2009;

±---------+

| count(*) |

±---------+

| 6422930 |

±---------+

1 row in set (0,00 sec)

then i did:

mysql> delete from logs_2009 where date >= ‘2009-01-01 00:00:00’ and date <= ‘2009-10-30 23:59:59’;
and then i counted the number of rows:

mysql> select count(*) from logs_2009;

±---------+

| count(*) |

±---------+

| 0 |

±---------+

1 row in set (0,00 sec)
In the directory $MYSQL/myBase, i still have too big MYD and MYI file:

-rw-rw---- 1 mysql mysql 8782 oct 4 2008 logs_2009.frm
-rw-rw---- 1 mysql mysql 2137037824 oct 22 13:24 logs_2009.MYI
-rw-rw---- 1 mysql mysql 1936289840 oct 22 13:25 logs_2009.MYD

Why the size of the MYD and MYI files wasn’t reduced even though all rows in the table were deleted ??


#2

Hi All,

For This just run below command

#mysqlcheck -u Username -p -o databasename