mysqldump slowing down the process?

Hi All,

   I have a data calculation process-a perl script running each and every hour which will do some calculations on the data stored in a mysql server. Normally it tooks around 2minutes \(max\) to complete.

   But in case if i did any actions on the linux box where the database is hosted, it is slowing down the process so as to finish the job in 30-50 minutes. I am just doing a mysqldump in the early hours of morning which is slowing down the very next process run. The process run is starting slowly but picking up it's speed and will finish up in it's own fashion, but overall 30-50 minutes it will consume.

I tried to do some optimization on the db server, moved the db server to a different box apart from where the perl script is running ie, loadserver but no change. I also noticed the io% consumed while the job is running and it is too high initially when the process start, then slows down gradually.

Here goes the version information:

MySQL:
        version    :   5.0.51a-24
        version_comment   :  (Debian)
        version_compile_machine :  i486
        version_compile_os  : debian-linux-gnu

Kernel version: 2.6.26-1-686 #1 SMP
Operating System: Debian 5.0 (lenny)
   Can anyone face the similar scenario? Any ideas on this? Your help is very much appreciated!

With Regards
Dileep Pattayath

First, please post the output of these mysql utilities (please use code tags when you post the output):

Thanks for your repsone Neo.

Here goes the output of mysqltuner.pl

 >>  MySQLTuner 1.0.0 - Major Hayden <major@mhtx.net>
 >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
 >>  Run with '--help' for additional options and output filtering
Please enter your MySQL administrative login: root
Please enter your MySQL administrative password: 
 
-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.0.51a-24
[!!] Switch to 64-bit OS - MySQL cannot currently use all of your RAM
 
-------- Storage Engine Statistics -------------------------------------------
[--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster 
[--] Data in MyISAM tables: 4G (Tables: 20)
[!!] InnoDB is enabled but isn't being used
[!!] Total fragmented tables: 1
 
-------- Performance Metrics -------------------------------------------------
[--] Up for: 10h 53m 40s (2M q [73.287 qps], 2K conn, TX: 1B, RX: 1B)
[--] Reads / Writes: 57% / 43%
[--] Total buffers: 1.1G global + 12.3M per thread (250 max threads)
[!!] Allocating > 2GB RAM on 32-bit systems can cause system instability
[!!] Maximum possible memory usage: 4.1G (109% of installed RAM)
[OK] Slow queries: 0% (5/2M)
[OK] Highest usage of available connections: 29% (73/250)
[OK] Key buffer size / total MyISAM indexes: 1.0G/658.7M
[OK] Key buffer hit rate: 99.5% (66M cached / 359K reads)
[!!] Query cache efficiency: 6.8% (115K cached / 1M selects)
[!!] Query cache prunes per day: 224366
[OK] Sorts requiring temporary tables: 0% (1 temp sorts / 769K sorts)
[OK] Temporary tables created on disk: 0% (48 on disk / 312K total)
[OK] Thread cache hit rate: 81% (476 created / 2K connections)
[OK] Table cache hit rate: 91% (65 open / 71 opened)
[OK] Open file limit used: 7% (102/1K)
[OK] Table locks acquired immediately: 99% (2M immediate / 2M locks)
 
-------- Recommendations -----------------------------------------------------
General recommendations:
    Add skip-innodb to MySQL configuration to disable InnoDB
    Run OPTIMIZE TABLE to defragment tables for better performance
    MySQL started within last 24 hours - recommendations may be inaccurate
    Enable the slow query log to troubleshoot bad queries
Variables to adjust:
  *** MySQL's maximum memory usage is dangerously high ***
  *** Add RAM before increasing MySQL buffer variables ***
    query_cache_limit (> 1M, or use smaller result sets)
    query_cache_size (> 32M)

Output of tuning-primer.sh


mysqld is alive
 
        -- MYSQL PERFORMANCE TUNING PRIMER --
             - By: Matthew Montgomery -
 
MySQL Version 5.0.51a-24 i486
 
Uptime = 0 days 10 hrs 56 min 36 sec
Avg. qps = 73
Total Questions = 2880082
Threads Connected = 32
 
Warning: Server has not been running for at least 48hrs.
It may not be safe to use these recommendations
 
To find out more information on how each of these
runtime variables effects performance visit:
http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html
Visit http://www.mysql.com/products/enterprise/advisors.html
for info about MySQL's Enterprise Monitoring and Advisory Service
 
SLOW QUERIES
The slow query log is NOT enabled.
Current long_query_time = 10 sec.
You have 5 out of 2880109 that take longer than 10 sec. to complete
Your long_query_time may be too high, I typically set this under 5 sec.
 
BINARY UPDATE LOG
The binary update log is NOT enabled.
You will not be able to do point in time recovery
See http://dev.mysql.com/doc/refman/5.0/en/point-in-time-recovery.html
 
WORKER THREADS
Current thread_cache_size = 8
Current threads_cached = 0
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine
 
MAX CONNECTIONS
Current max_connections = 250
Current threads_connected = 33
Historic max_used_connections = 73
The number of used connections is 29% of the configured maximum.
Your max_connections variable seems to be fine.
 
MEMORY USAGE
Max Memory Ever Allocated : 1.91 G
Configured Max Per-thread Buffers : 3.00 G
Configured Max Global Buffers : 1.04 G
Configured Max Memory Limit : 4.04 G
Physical Memory : 3.71 G
 
Max memory limit exceeds 90% of physical memory
 
KEY BUFFER
568333 * 1024 / 1073741824 * 100
Current MyISAM index space = 658 M
Current key_buffer_size = 1.00 G
Key cache miss rate is 1 : 183
Key buffer free ratio = 0 %
Your key_buffer_size seems to be too high.
Perhaps you can use these resources elsewhere
 
QUERY CACHE
Query cache is enabled
Current query_cache_size = 32 M
Current query_cache_used = 1 M
Current query_cache_limit = 1 M
Current Query cache Memory fill ratio = 5.96 %
Current query_cache_min_res_unit = 4 K
Query Cache is 21 % fragmented
Run "FLUSH QUERY CACHE" periodically to defragment the query cache memory
If you have many small queries lower 'query_cache_min_res_unit' to reduce fragmentation.
Your query_cache_size seems to be too high.
Perhaps you can use these resources elsewhere
MySQL won't cache query results that are larger than query_cache_limit in size
 
SORT OPERATIONS
Current sort_buffer_size = 2 M
Current read_rnd_buffer_size = 7 M
Sort buffer seems to be fine
 
JOINS
Current join_buffer_size = 132.00 K
You have had 2 queries where a join could not use an index properly
You should enable "log-queries-not-using-indexes"
Then look for non indexed joins in the slow query log.
If you are unable to optimize your queries you may want to increase your
join_buffer_size to accommodate larger joins in one pass.
 
Note! This script will still suggest raising the join_buffer_size when
ANY joins not using indexes are found.
 
OPEN FILES LIMIT
Current open_files_limit = 1284 files
The open_files_limit should typically be set to at least 2x-3x
that of table_cache if you have heavy MyISAM usage.
Your open_files_limit value seems to be fine
 
TABLE CACHE
Current table_cache value = 512 tables
You have a total of 37 tables
You have 65 open tables.
The table_cache value seems to be fine
 
TEMP TABLES
Current max_heap_table_size = 16 M
Current tmp_table_size = 32 M
Of 312629 temp tables, 0% were created on disk
Effective in-memory tmp_table_size is limited to max_heap_table_size.
Created disk tmp tables ratio seems fine
 
TABLE SCANS
Current read_buffer_size = 1 M
Current table scan ratio = 23 : 1
read_buffer_size seems to be fine
 
TABLE LOCKING
Current Lock Wait ratio = 1 : 2111
You may benefit from selective use of InnoDB.
If you have long running SELECT's against MyISAM tables and perform
frequent updates consider setting 'low_priority_updates=1'
If you have a high concurrency of inserts on Dynamic row-length tables
consider setting 'concurrent_insert=2'.

With Regards
Dileep Pattayath

Do you know what are your first steps based on these basic tuning results?

I understand some of them, but not sure how to proceed with this. I am expecting some guidence from you if you dont mind please..

No problem at all. I just wanted to get your ideas first, so we can have a two-way dialog, not just one way.

First, I suggest you decrease your maximum number of SQL connections to 100 to save memory, since you are very low on memory, according to the tuning scripts.

At the same time you do this increase your query cache size to 128 MB, as a first step.

Do you know how to do this?

ok, i will increase my query cache to 128mb as you said.The number of connections was 100 before and i modified it few days ago after i faced an issue with the connection limit. The figure the script is showing (74) is because i restarted my server yesterday early morning. What else i was supposed to do?

Hi Neo, do you think i have to increase the query_cache_limit size also. The comment says that "MySQL won't cache query results that are larger than query_cache_limit in size".

Can you please suggest what else i have to modify according to the optimization results?