MySQL Optimal Settings

Hi all

I need all your advices regarding the performance of my Database. Our database was running fine and now it is lagging when there are more users.

Let me explain

We are using MySQL 4.0

1.We have tables having records more than 100,000

2.Our tables are growing by min 200 records per day

3.We have applied index for frequent usage and huge table.

4.We have modified the my.ini file to use the max resources

5.Our database server is running on a Windows 2000 server with 1 GB RAM

Still , the site is lagging and the MySql database residing server is showing 100% CPU usage.

So please, help me if our procedure are correct and any thing we are missing.

All advices are highly valued and please help

Thank you all

I would start with the slow query log to see whats happening.

Thanks linuxrunner for the replay )

1.Yes i do checked slow queries,
2.I have few queries of 3-5 seconds execution time.
3.I have optimized some of them
4.The are 2 tables , one OrderMaster, and other OrderDetail
the SQL running on this tables are slower.

5.They have index for the search fields in this tables
6.The master tbl have 116,524 Recs,
and detail tbl have 453,465 recs
7.And also we have applications accessing these tables in
regular time interval
8. So these tables are busy.
9.Since these tables have all data , and we only use data not
older than 3 months ,
10.Is it a best idea to remove those unused data to archive DB.
11.Thus making these tables less weight
12.Will produce better response time
13 Or is there any other setting or consideration we have to change to get better response time and reduce CPU usage.

expecting the reply soon , pls

thank you


can you post output of SHOW VARIABLES and SHOW GLOBAL STATUS?

Also what is the size of your database?

Hai tanj

The database size is about 120 MB
The MySQL version is 4.0.17

expecting your reply
Thank You

This are the variables

Show Variables Listing


‘character_sets’,‘latin1 big5 czech euc_kr gb2312 gbk latin1_de sjis tis620 ujis dec8 dos german1 hp8 koi8_ru latin2 swe7 usa7 cp1251 danish hebrew win1251 estonia hungarian koi8_ukr win1251ukr greek win1250 croat cp1257 latin5’
‘ft_boolean_syntax’,’+ -><()~*:""&|’
‘timezone’,‘Arab Standard Time’
‘version_comment’,‘Source distribution’


thanks for posting Status variables. Can you also post SHOW STATUS output so I would see where the performance bottlenecks could be?

120MB is quite small size for database and I’m used to play with tables having 4 million records or more. So it should be no problem for your config )

I suspect that your database usage may have bad joins or table scans. But I need output of SHOW STATUS or slow query log for this.


Hi tanj
Thank tanj
Below are the Status values , these values not at peak , took them at morning .


show status


Hello mimayls

Thanks for the status values, it proves instructive.


Is showing that your queries are doing, most of the time, table scans instead of index reads. Looks like you’ll have to review most of your queries’ execution plans (i.e. take the queries and EXPLAIN on them). Maybe you will want to post some examples of query and EXPLAIN query so I could give you more advice.

About the configuration, you might want to increase the tmp_table_size to 64M (it shows that you have a lot of on-disk temporary tables created)

Also I see that your query cache size is 256M, but only 1M is used. It’s way too large. In regards to your database size I recommend that you set query_cache_size to 8M, so you will free unnecessary reserved memory.


Hai tanj
Thank you for the suggections.

Can you please tell me
1.why query cache is used only 1MB,
Because query are small size Or There is another problem

2.Why there are large no. of tmp tables
This is the problem of the unoptimized queries?
Lack of indexes in the table

please guid me

Thank You

I am wondering about the box… 1Gb, Windows 2000, 100% CPU!

100% CPU may happen when:

  • paging is used due to not enough RAM
  • a lot of calculations such as in-memory sort (bad database schema)

Database is small (possibly 100 Mb on hard drive, isn’t it?); 200 new records per day should not overload anything.

I’d check the box at first… And the schema. Everything must work with default ‘tuning parameters’. Do you run any other applications on the same Windows box? Is RAM enough? Can you check Windows Task Manager?


3.We have applied index for frequent usage and huge table.

You should apply indexes as needed… and remove indexes not needed. Table size and usage frequency does not play any role; analyze all SQL statements, and check with EXPLAIN

Thank you bambarbia
Sure we have to review our Schema and the Queries.
No other application running on the server
The Server is same as mentioned earlier
We have multilpe client applications accessing the server regularly for every 10 second.This applications checks ordermaster table.

Can u please check the system variables , if they are correct.

Thank you