PDA

View Full Version : Database Optimisation Issue


veenuisthebest
03-08-2009, 04:24 PM
Hiii..

I have 2 different vb databases, small enough, just around 10-12 MB each.

Now, issue is that my Site A has a very optimized database BUT my Site B doesn't.
Reason I say this is simple:-

1. Both have same resources, same db size but Site A runs smooth and faster than Site B.

2. When I try to optimize databases from admincp, Site A optimises in not more than 2 seconds and shows "Table is up to date" for almost every table WHEREAS Site B hangs inbetween while optimization, and I have to do it per 10-20 at a time. It hardly shows "Table is up to date" for any table.

3. Now, while investigating the issue, I noticed that tables in Site A show very accurate Data Length for every table BUT Site B has most of the table's Data Length to same 16 KB each (even when they are empty i.e. 0 bytes). Its something similar with both site tables Index Length too.

So, how do I make Site B as good as Site A. That 16 KB is surely some problem.

Thanks

Lynne
03-08-2009, 04:56 PM
Are both the sites on the same server or on different servers?

veenuisthebest
03-09-2009, 01:53 AM
Both are on same server!

Lynne, I am sure this has to do with Site B's database only. Something needs to be done manually.

Dismounted
03-09-2009, 05:00 AM
Do both sites have the same modifications installed? Do they have the same number of people online?

These, and more variables, will affect a site's loading time.

BSMedia
03-09-2009, 05:04 AM
Try to run myisamchk from the SSH prompt for each table

veenuisthebest
03-09-2009, 05:04 AM
yes! Exactly same modifications. Both have light traffic and almost same.

I am not talking about site's loading time BUT the database optimization issue with Site B. Why is it showing 16kb data length for tables that have nothing, whereas, Site A shows correct as 0 bytes.

Lynne
03-09-2009, 03:04 PM
Sometimes you have to run optimize (or repair) a couple of times.

veenuisthebest
03-09-2009, 04:37 PM
Ofcourse, running it twice or thrice is not making any difference.

BSMedia
03-09-2009, 04:49 PM
Login via SSH and run myisamchk on each individual table.

You'll have to browse to the mysql folder where the .MYI type files are stored, and run it like

myisamchk -r table_name.MYI

or

myisamchk -r *.MYI

veenuisthebest
03-09-2009, 04:58 PM
oh I missed your previous post somewhow. Thanks for reply BS.

I forgot to tell that its a shared server and ofcourse, no SSH. But I do have a new server now, so I'll try to get Site B's database up there and run myisamchk. Will post results.

Thanks

BSMedia
03-09-2009, 06:13 PM
No problem!

You may have to do it two to three times.

Try not to use the vBulletin repair tool, not only can it repair tables, but it can also break your database, its usually always best to SSH if available :D

Good luck

veenuisthebest
03-09-2009, 09:13 PM
Got the database up onto the new server. Could see the forum running as well.

Then when I ran the command "myisamchk -r *.MYI", all tables got corrupted.

Now, when I run "mysqlcheck -r -u USERNAME -p DATABASENAME", it shows the following for ALL tables.

Error : Incorrect information in file: './database/table.frm'
error : Corrupt

How did .frm got corrupt for all tables??

--------------- Added 1236638955 at 1236638955 ---------------

ALRIGHT..

So, I tried everything again. Reuploaded the backup, ran a mysqlcheck, then a myisamchk, and all went FINE.

mysqlcheck -r -u USERNAME -p DATABASENAME

myisamchk -r /path/to/database/dir/*.MYI

mysqlcheck -r -o USERNAME -p DATABASENAME


I can now see all tables being optimised quickly! and all show "Table is already upto date" after running optimization a couple of times. I also found 5 tables named something like aggregrate_temp_12515 etc. I deleted all 5.

Looking great uptill now.

Thanks

--------------- Added 1236661081 at 1236661081 ---------------

I finally took the backup of the FINE TUNED database and got it up. Everything working as expected. See I told you all it was a database issue :D