database.sarang.net
UserID
Passwd
Database
DBMS
ㆍMySQL
PostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
MySQL Q&A 29495 게시물 읽기
No. 29495
MySQL 느려지는 현상
작성자
H맨
작성일
2010-01-06 15:43ⓒ
2010-01-06 15:44ⓜ
조회수
8,277

OS: CentOS 4.5
MySQL 버젼: 4.0.26
메모리: 8GB
                  total       used       free     shared    buffers     cached
Mem:       8165400    1692012    6473388          0     158572    1144512
-/+ buffers/cache:     388928    7776472
Swap:      4192924          0    4192924

아래와 같이 쓰레드 증가하면서 굉장히 느려집니다. 머가 문제일까요? 쓰레드가 30이상정도 되면 느려지고 보통 최대300까지 갑니다. 정상적일때에는 10 왔다갔다 합니다. variables 정보도 첨부합니다.

Uptime: 979  Threads: 125  Questions: 123441  Slow queries: 148  Opens: 210  Flush tables: 1  Open tables: 204  Queries per second avg: 126.089                                                                                  

 Locked          select id,code,img_file1,img_file2,title,subtitle,day,count,title_check,passwd,notice,gonews_id,coop
 Locked          select id,code,img_file1,img_file2,title,subtitle,day,count,title_check,passwd,notice,gonews_id,coop
 Sending data    select id,code,img_file1,img_file2,title,subtitle,day,count,title_check,passwd,notice,gonews_id,coop
 Sending data    select id,code,img_file1,img_file2,title,subtitle,day,count,title_check,passwd,notice,gonews_id,coop
 Sorting result  select id,code,img_file1,img_file2,title,subtitle,day,count,title_check,passwd,notice,gonews_id,coop
 Sending data    select id,code,img_file1,img_file2,title,subtitle,day,count,title_check,passwd,notice,gonews_id,coop
 Sending data    select id,code,img_file1,img_file2,title,subtitle,day,count,title_check,passwd,notice,gonews_id,coop
 Sending data    select id,code,img_file1,img_file2,title,subtitle,day,count,title_check,passwd,notice,gonews_id,coop
 Sending data    select id,code,img_file1,img_file2,title,subtitle,day,count,title_check,passwd,notice,gonews_id,coop
 Locked          select id,code,img_file1,img_file2,title,subtitle,day,count,title_check,passwd,notice,gonews_id,coop
 Locked          select id,code,img_file1,img_file2,title,subtitle,day,count,title_check,passwd,notice,gonews_id,coop
 Locked          select id,code,img_file1,img_file2,title,subtitle,day,count,title_check,passwd,notice,gonews_id,coop
 Locked          select id,code,img_file1,img_file2,title,subtitle,day,count,title_check,passwd,notice,gonews_id,coop
 Locked          select id,code,img_file1,img_file2,title,subtitle,day,count,title_check,passwd,notice,gonews_id,coop
 Locked          select id,code,img_file1,img_file2,title,subtitle,day,count,title_check,passwd,notice,gonews_id,coop
 Locked          select id,code,img_file1,img_file2,title,subtitle,day,count,title_check,passwd,notice,gonews_id,coop
 Locked          select id,code,img_file1,img_file2,title,subtitle,day,count,title_check,passwd,notice,gonews_id,coop
 Sending data    select count(*) from board_news where code='entertainment' and  board_flag=0 and notice=0 and topnew
 Locked          select id,code,img_file1,img_file2,title,subtitle,day,count,title_check,passwd,notice,gonews_id,coop
 Locked          select id,code,img_file1,img_file2,title,subtitle,day,count,title_check,passwd,notice,gonews_id,coop
 Locked          select id,code,img_file1,img_file2,title,subtitle,day,count,title_check,passwd,notice,gonews_id,coop
 Sending data    select count(*) from board_news where code='entertainment' and  board_flag=0 and notice=0 and topnew
 Sending data    select count(*) from board_news where code='entertainment' and  board_flag=0 and notice=0 and topnew
 Locked          select id,code,img_file1,img_file2,title,subtitle,day,count,title_check,passwd,notice,gonews_id,coop
 Locked          select id,code,img_file1,img_file2,title,subtitle,day,count,title_check,passwd,notice,gonews_id,coop
 Locked          update board_news set count=count+1 where id=492339                                                 
 Locked          update board_news set count=count+1 where id=492230                                                 
 Locked          update board_news set count=count+1 where id=492230                                                 
 Locked          update board_news set count=count+1 where id=492169                                                 
 Locked          update board_news set count=count+1 where id=492230                                                 
 Locked          update board_news set count=count+1 where id=480577                                                 
 Locked          update board_news set count=count+1 where id=64728                                                  
 Locked          update board_news set count=count+1 where id=492077                                                 
 Locked          update board_news set count=count+1 where id=8385                                                   
 Locked          update board_news set count=count+1 where id=482114                                                 
 Locked          update board_news set count=count+1 where id=492455                                                 
 Locked          update board_news set count=count+1 where id=480155                                                 
 Locked          update board_news set count=count+1 where id=480587                                                 
 Locked          update board_news set count=count+1 where id=492170                                                 
 Locked          update board_news set count=count+1 where id=492169                                                 
 Locked          update board_news set count=count+1 where id=25528                                                  
 Locked          update board_news set count=count+1 where id=342336                                                 
 Locked          update board_news set count=count+1 where id=492462                                                 
 Locked          update board_news set count=count+1 where id=492230                                                 
 Locked          update board_news set count=count+1 where id=241003                                                 
 Locked          update board_news set count=count+1 where id=492455                                                 
 Locked          update board_news set count=count+1 where id=492525                                                 
 Locked          update board_news set count=count+1 where id=492534                                                 
 Locked          update board_news set count=count+1 where id=492170                                                 
 Locked          update board_news set count=count+1 where id=492170                                                 
 Locked          update board_news set count=count+1 where id=453294                                                 
 Locked          update board_news set count=count+1 where id=66134                                                  
 Locked          update board_news set count=count+1 where id=487686                                                 
 Locked          select id from board_news where notice=1                                                            
 Locked          select * from board_news where id=461163                                                            
 Locked          select * from board_news where id=492110                                                            
 Locked          select * from board_news where id=302787                                                            
 Locked          select * from board_news where id=483866                                                            
 Locked          select * from board_news where id=492226                                                            
 Locked          select * from board_news where id=336847                                                            
 Locked          select * from board_news where id=492456                                                            
 Locked          select * from board_news where id=38237                                                             
 Locked          update board_news set count=count+1 where id=492534                                                 
 Locked          update board_news set count=count+1 where id=492170                                                 
 Locked          select * from board_news where id=492226                                                            
 Locked          select * from board_news where id=492226                                                            
 Locked          select * from board_news where id=63331                                                             
 Locked          select id from board_news where notice=1                                                            
 Locked          select * from board_news where id=492523                                                            
 Locked          select * from board_news where id=8637                                                              
 Locked          select * from board_news where id=492226                                                            
 Locked          select * from board_news where id=492226                                                            
 Locked          select * from board_news where id=465138                                                            
 Locked          select * from board_news where id=446489                                                            
 Locked          select * from board_news where id=492457                                                            
 Locked          select * from board_news where id=453294                                                            
 Locked          select * from board_news where id=64349                                                             
 Locked          select * from board_news where id=484820                                                            
 Locked          select * from board_news where id=492226                                                            
 Locked          update board_news set count=count+1 where id=487686                                                 
 Locked          select * from board_news where id=492228                                                            
 Locked          select * from board_news where id=492189                                                            
 Locked          update board_news set count=count+1 where id=491772                                                 
 Locked          select * from board_news where id=459428                                                            
 Locked          select id from board_news where notice=1                                                            
 Locked          select * from board_news where id=461374                                                            
 Locked          select * from board_news where id=492523                                                            
 Locked          select count(*) from board_news where code='entertainment' and  board_flag=0 and notice=0 and topnew
 Locked          select * from board_news where id=492517                                                            
 Locked          select * from board_news where id=492226                                                            
 Locked          select * from board_news where id=1113                                                              
 Locked          update board_news set count=count+1 where id=492534                                                 
 Locked          select * from board_news where id=481148                                                            
 Locked          select * from board_news where id=492226                                                            
 Locked          select * from board_news where id=34084                                                             
 Locked          select * from board_news where id=55715                                                             
 Locked          select * from board_news where id=492226                                                            
 Locked          select * from board_news where id=492226

+---------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Variable_name                   | Value                                                                                                                                                                                                             |
+---------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| back_log                        | 50                                                                                                                                                                                                                |
| basedir                         | /data/mysql/                                                                                                                                                                                                      |
| binlog_cache_size               | 1048576                                                                                                                                                                                                           |
| bulk_insert_buffer_size         | 8388608                                                                                                                                                                                                           |
| character_set                   | latin1                                                                                                                                                                                                            |
| character_sets                  | latin1 big5 cp1251 cp1257 croat czech danish dec8 dos estonia euc_kr gb2312 gbk german1 greek hebrew hp8 hungarian koi8_ru koi8_ukr latin1_de latin2 latin5 sjis swe7 tis620 ujis usa7 win1250 win1251ukr win1251 |
| concurrent_insert               | ON                                                                                                                                                                                                                |
| connect_timeout                 | 5                                                                                                                                                                                                                 |
| convert_character_set           |                                                                                                                                                                                                                   |
| datadir                         | /data/mysql/data/                                                                                                                                                                                                 |
| default_week_format             | 0                                                                                                                                                                                                                 |
| delay_key_write                 | ON                                                                                                                                                                                                                |
| delayed_insert_limit            | 100                                                                                                                                                                                                               |
| delayed_insert_timeout          | 300                                                                                                                                                                                                               |
| delayed_queue_size              | 1000                                                                                                                                                                                                              |
| flush                           | OFF                                                                                                                                                                                                               |
| flush_time                      | 0                                                                                                                                                                                                                 |
| ft_boolean_syntax               | + -><()~*:""&|                                                                                                                                                                                                    |
| ft_max_word_len                 | 254                                                                                                                                                                                                               |
| ft_max_word_len_for_sort        | 20                                                                                                                                                                                                                |
| ft_min_word_len                 | 4                                                                                                                                                                                                                 |
| ft_stopword_file                | (built-in)                                                                                                                                                                                                        |
| have_bdb                        | NO                                                                                                                                                                                                                |
| have_crypt                      | YES                                                                                                                                                                                                               |
| have_innodb                     | YES                                                                                                                                                                                                               |
| have_isam                       | YES                                                                                                                                                                                                               |
| have_openssl                    | NO                                                                                                                                                                                                                |
| have_query_cache                | YES                                                                                                                                                                                                               |
| have_raid                       | NO                                                                                                                                                                                                                |
| have_symlink                    | YES                                                                                                                                                                                                               |
| init_file                       |                                                                                                                                                                                                                   |
| innodb_additional_mem_pool_size | 20971520                                                                                                                                                                                                          |
| innodb_autoextend_increment     | 8                                                                                                                                                                                                                 |
| innodb_buffer_pool_size         | 402653184                                                                                                                                                                                                         |
| innodb_data_file_path           | ibdata1:2000M;ibdata2:10M:autoextend                                                                                                                                                                              |
| innodb_data_home_dir            | /data/mysql/data/                                                                                                                                                                                                 |
| innodb_fast_shutdown            | ON                                                                                                                                                                                                                |
| innodb_file_io_threads          | 4                                                                                                                                                                                                                 |
| innodb_flush_log_at_trx_commit  | 1                                                                                                                                                                                                                 |
| innodb_flush_method             |                                                                                                                                                                                                                   |
| innodb_force_recovery           | 0                                                                                                                                                                                                                 |
| innodb_lock_wait_timeout        | 10                                                                                                                                                                                                                |
| innodb_log_arch_dir             | /data/mysql/data/                                                                                                                                                                                                 |
| innodb_log_archive              | OFF                                                                                                                                                                                                               |
| innodb_log_buffer_size          | 8388608                                                                                                                                                                                                           |
| innodb_log_file_size            | 104857600                                                                                                                                                                                                         |
| innodb_log_files_in_group       | 2                                                                                                                                                                                                                 |
| innodb_log_group_home_dir       | /data/mysql/data/                                                                                                                                                                                                 |
| innodb_max_dirty_pages_pct      | 90                                                                                                                                                                                                                |
| innodb_max_purge_lag            | 0                                                                                                                                                                                                                 |
| innodb_mirrored_log_groups      | 1                                                                                                                                                                                                                 |
| innodb_table_locks              | ON                                                                                                                                                                                                                |
| innodb_thread_concurrency       | 8                                                                                                                                                                                                                 |
| interactive_timeout             | 28800                                                                                                                                                                                                             |
| join_buffer_size                | 131072                                                                                                                                                                                                            |
| key_buffer_size                 | 402653184                                                                                                                                                                                                         |
| language                        | /data/mysql/share/mysql/english/                                                                                                                                                                                  |
| large_files_support             | ON                                                                                                                                                                                                                |
| license                         | GPL                                                                                                                                                                                                               |
| local_infile                    | ON                                                                                                                                                                                                                |
| locked_in_memory                | OFF                                                                                                                                                                                                               |
| log                             | OFF                                                                                                                                                                                                               |
| log_bin                         | ON                                                                                                                                                                                                                |
| log_error                       |                                                                                                                                                                                                                   |
| log_slave_updates               | OFF                                                                                                                                                                                                               |
| log_slow_queries                | ON                                                                                                                                                                                                                |
| log_update                      | OFF                                                                                                                                                                                                               |
| log_warnings                    | 1                                                                                                                                                                                                                 |
| long_query_time                 | 3                                                                                                                                                                                                                 |
| low_priority_updates            | OFF                                                                                                                                                                                                               |
| lower_case_file_system          | OFF                                                                                                                                                                                                               |
| lower_case_table_names          | 0                                                                                                                                                                                                                 |
| max_allowed_packet              | 8387584                                                                                                                                                                                                           |
| max_binlog_cache_size           | 4294967295                                                                                                                                                                                                        |
| max_binlog_size                 | 1073741824                                                                                                                                                                                                        |
| max_connect_errors              | 9999                                                                                                                                                                                                              |
| max_connections                 | 1900                                                                                                                                                                                                              |
| max_delayed_threads             | 20                                                                                                                                                                                                                |
| max_heap_table_size             | 16777216                                                                                                                                                                                                          |
| max_insert_delayed_threads      | 20                                                                                                                                                                                                                |
| max_join_size                   | 18446744073709551615                                                                                                                                                                                              |
| max_relay_log_size              | 0                                                                                                                                                                                                                 |
| max_seeks_for_key               | 4294967295                                                                                                                                                                                                        |
| max_sort_length                 | 1024                                                                                                                                                                                                              |
| max_tmp_tables                  | 32                                                                                                                                                                                                                |
| max_user_connections            | 0                                                                                                                                                                                                                 |
| max_write_lock_count            | 4294967295                                                                                                                                                                                                        |
| myisam_max_extra_sort_file_size | 268435456                                                                                                                                                                                                         |
| myisam_max_sort_file_size       | 9223372036854775807                                                                                                                                                                                               |
| myisam_recover_options          | OFF                                                                                                                                                                                                               |
| myisam_repair_threads           | 1                                                                                                                                                                                                                 |
| myisam_sort_buffer_size         | 67108864                                                                                                                                                                                                          |
| net_buffer_length               | 16384                                                                                                                                                                                                             |
| net_read_timeout                | 30                                                                                                                                                                                                                |
| net_retry_count                 | 10                                                                                                                                                                                                                |
| net_write_timeout               | 60                                                                                                                                                                                                                |
| new                             | OFF                                                                                                                                                                                                               |
| open_files_limit                | 10102                                                                                                                                                                                                             |
| pid_file                        | /data/mysql/data/localhost.localdomain.pid                                                                                                                                                                        |
| port                            | 3306                                                                                                                                                                                                              |
| protocol_version                | 10                                                                                                                                                                                                                |
| query_alloc_block_size          | 8192                                                                                                                                                                                                              |
| query_cache_limit               | 1048576                                                                                                                                                                                                           |
| query_cache_size                | 268435456                                                                                                                                                                                                         |
| query_cache_type                | ON                                                                                                                                                                                                                |
| query_cache_wlock_invalidate    | OFF                                                                                                                                                                                                               |
| query_prealloc_size             | 8192                                                                                                                                                                                                              |
| range_alloc_block_size          | 2048                                                                                                                                                                                                              |
| read_buffer_size                | 2093056                                                                                                                                                                                                           |
| read_only                       | OFF                                                                                                                                                                                                               |
| read_rnd_buffer_size            | 8384512                                                                                                                                                                                                           |
| rpl_recovery_rank               | 0                                                                                                                                                                                                                 |
| server_id                       | 1                                                                                                                                                                                                                 |
| skip_external_locking           | ON                                                                                                                                                                                                                |
| skip_networking                 | OFF                                                                                                                                                                                                               |
| skip_show_database              | OFF                                                                                                                                                                                                               |
| slave_net_timeout               | 3600                                                                                                                                                                                                              |
| slow_launch_time                | 2                                                                                                                                                                                                                 |
| socket                          | /tmp/mysql.sock                                                                                                                                                                                                   |
| sort_buffer_size                | 4194296                                                                                                                                                                                                           |
| sql_mode                        | 0                                                                                                                                                                                                                 |
| table_cache                     | 4096                                                                                                                                                                                                              |
| table_type                      | MYISAM                                                                                                                                                                                                            |
| thread_cache_size               | 20                                                                                                                                                                                                                |
| thread_stack                    | 196608                                                                                                                                                                                                            |
| timezone                        | KST                                                                                                                                                                                                               |
| tmp_table_size                  | 33554432                                                                                                                                                                                                          |
| tmpdir                          | /tmp/                                                                                                                                                                                                             |
| transaction_alloc_block_size    | 8192                                                                                                                                                                                                              |
| transaction_prealloc_size       | 4096                                                                                                                                                                                                              |
| tx_isolation                    | REPEATABLE-READ                                                                                                                                                                                                   |
| version                         | 4.0.26-log                                                                                                                                                                                                        |
| version_comment                 | Source distribution                                                                                                                                                                                               |
| version_compile_os              | unknown-linux-gnu                                                                                                                                                                                                 |
| wait_timeout                    | 28800                                                                                                                                                                                                             |
+---------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

이 글에 대한 댓글이 총 1건 있습니다.

SELECT COUNT(*) FROM board_news 쿼리 때문에 나머지 UPDATE 쿼리가 전부 LOCKED 되고 있습니다.

SELECT COUNT(*) 계열 쿼리의 속도를 개선해줘야 할 것으로 보이네요.

해당 쿼리의 WHERE 절에서 자주 사용되는 컬럼집합에 대한 인덱스가 설정 여부에 따라 속도는 크게 달라질 수 있으리라 생각됩니다.

지나치게 하나의 테이블에 종속적인 설계때문일 수도 있으니, 테이블 분리도 생각해보시는 것이 좋겠습니다 ^^

(이를테면 code에 따라 테이블을 분리할 수도 있겠지요)

박현우(lqez)님이 2010-01-07 17:55에 작성한 댓글입니다.
[Top]
No.
제목
작성자
작성일
조회
29498통계 내는 쿼리가 궁금합니다. [4]
궁금이
2010-01-07
6864
29497한글 사용하려면 소스로 설치해야 하나요? [3]
네오
2010-01-06
7046
29496그룹으로 묶는 쿼리문. [1]
강민정
2010-01-06
6522
29495MySQL 느려지는 현상 [1]
H맨
2010-01-06
8277
29494쿼리에 응답이 너무너무너무 느려요 ㅠㅠ [1]
염진근
2010-01-04
7044
29493like ? 이 무슨 뜻인가요??? [2]
테스트
2010-01-04
6661
29492[트리거]mysql -> 오라클 가능한가요? [1]
푸르미
2009-12-28
6932
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.020초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다