ioannisg

Registered
Feb 1, 2013
1
0
1
cPanel Access Level
Website Owner
Hello I new here and I have this problem with my mysql in my server. I have a dedicated server with 8 cpus and 12GB with two SSD hard disks. But I have a very slow site.
My problems is a very slow query in mysgl :

SELECT SQL_CALC_FOUND_ROWS products.*, descr1.product as product, MIN(prices.price) as price, descr1.short_description, IF(descr1.short_description = '', descr1.full_description, '') as full_description, GROUP_CONCAT(IF(products_categories.link_type = 'M', CONCAT(products_categories.category_id, 'M'), products_categories.category_id)) as category_ids, products_categories.position, cscart_seo_names.name as seo_name FROM cscart_products as products LEFT JOIN cscart_product_features_values ON cscart_product_features_values.product_id = products.product_id AND cscart_product_features_values.lang_code = 'EL' LEFT JOIN (SELECT product_id, GROUP_CONCAT(cscart_product_features_values.variant_id) AS simple_variants FROM cscart_product_features_values WHERE lang_code = 'EL' GROUP BY product_id) AS pfv_simple ON pfv_simple.product_id = products.product_id LEFT JOIN cscart_product_descriptions as descr1 ON descr1.product_id = products.product_id AND descr1.lang_code = 'EL' LEFT JOIN cscart_product_prices as prices ON prices.product_id = products.product_id AND prices.lower_limit = 1 INNER JOIN cscart_products_categories as products_categories ON products_categories.product_id = products.product_id INNER JOIN cscart_categories ON cscart_categories.category_id = products_categories.category_id AND (cscart_categories.usergroup_ids = '' OR FIND_IN_SET(0, cscart_categories.usergroup_ids) OR FIND_IN_SET(1, cscart_categories.usergroup_ids)) AND cscart_categories.status IN ('A', 'H') LEFT JOIN cscart_seo_names ON cscart_seo_names.object_id = products.product_id AND cscart_seo_names.type = 'p' AND cscart_seo_names.dispatch = '' AND cscart_seo_names.lang_code = 'EL' WHERE 1 AND FIND_IN_SET('2073', simple_variants) AND products.company_id = 0 AND (products.usergroup_ids = '' OR FIND_IN_SET(0, products.usergroup_ids) OR FIND_IN_SET(1, products.usergroup_ids)) AND products.status IN ('A') AND prices.usergroup_id IN (0, 0, 1) GROUP BY products.product_id ORDER BY products_categories.position asc LIMIT 592, 16
which does a lot of joins without indexes.

Code:
[email protected] [~]# ./mysqltuner.pl

 >>  MySQLTuner 1.2.0 - Major Hayden <[email protected]>
 >>  Bug reports, feature requests, and downloads at [url]http://mysqltuner.com/[/url]
 >>  Run with '--help' for additional options and output filtering

-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.1.67-cll
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -------------------------------------------
[--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 483M (Tables: 1584)
[--] Data in InnoDB tables: 208K (Tables: 13)
[--] Data in MEMORY tables: 0B (Tables: 1)
[!!] Total fragmented tables: 14

-------- Security Recommendations  -------------------------------------------
[OK] All database users have passwords assigned

-------- Performance Metrics -------------------------------------------------
[--] Up for: 3d 17h 0m 23s (30M q [96.343 qps], 482K conn, TX: 26B, RX: 9B)
[--] Reads / Writes: 73% / 27%
[--] Total buffers: 3.3G global + 18.6M per thread (500 max threads)
[!!] Maximum possible memory usage: 12.4G (216% of installed RAM)
[OK] Slow queries: 0% (1/30M)
[OK] Highest usage of available connections: 10% (51/500)
[OK] Key buffer size / total MyISAM indexes: 1.0G/236.7M
[OK] Key buffer hit rate: 99.9% (604M cached / 309K reads)
[OK] Query cache efficiency: 94.3% (26M cached / 28M selects)
[!!] Query cache prunes per day: 206296
[OK] Sorts requiring temporary tables: 0% (82 temp sorts / 764K sorts)
[!!] Joins performed without indexes: 24054
[!!] Temporary tables created on disk: 37% (401K on disk / 1M total)
[OK] Thread cache hit rate: 99% (70 created / 482K connections)
[!!] Table cache hit rate: 2% (1K open / 44K opened)
[OK] Open file limit used: 20% (2K/9K)
[OK] Table locks acquired immediately: 99% (5M immediate / 5M locks)
[OK] InnoDB data size / buffer pool: 208.0K/8.0M

-------- Recommendations -----------------------------------------------------
General recommendations:
    Run OPTIMIZE TABLE to defragment tables for better performance
    Reduce your overall MySQL memory footprint for system stability
    Increasing the query_cache size over 128M may reduce performance
    Adjust your join queries to always utilize indexes
    Temporary table size is already large - reduce result set size
    Reduce your SELECT DISTINCT queries without LIMIT clauses
    Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
  *** MySQL's maximum memory usage is dangerously high ***
  *** Add RAM before increasing MySQL buffer variables ***
    query_cache_size (> 256M) [see warning above]
    join_buffer_size (> 16.0M, or always use indexes with joins)
    table_cache (> 1024)
Code:
[email protected] [~]# sh ~/tuning-primer.sh

        -- MYSQL PERFORMANCE TUNING PRIMER --
             - By: Matthew Montgomery -

MySQL Version 5.1.67-cll x86_64

Uptime = 3 days 17 hrs 19 min 35 sec
Avg. qps = 96
Total Questions = 31173461
Threads Connected = 1

Server has been running for over 48hrs.
It should be safe to follow these recommendations

To find out more information on how each of these
runtime variables effects performance visit:
[url=http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html]MySQL :: MySQL 5.1 Reference Manual :: 5.1.4 Server System Variables[/url]
Visit [url=http://www.mysql.com/products/enterprise/advisors.html]MySQL :: MySQL Enterprise Advisors[/url]
for info about MySQL's Enterprise Monitoring and Advisory Service

SLOW QUERIES
The slow query log is enabled.
Current long_query_time = 10.000000 sec.
You have 1 out of 31173482 that take longer than 10.000000 sec. to complete
Your long_query_time seems to be fine

BINARY UPDATE LOG
The binary update log is NOT enabled.
You will not be able to do point in time recovery
See [url=http://dev.mysql.com/doc/refman/5.1/en/point-in-time-recovery.html]MySQL :: MySQL 5.1 Reference Manual :: 7.5 Point-in-Time (Incremental) Recovery Using the Binary Log[/url]

WORKER THREADS
Current thread_cache_size = 16
Current threads_cached = 15
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine

MAX CONNECTIONS
Current max_connections = 500
Current threads_connected = 1
Historic max_used_connections = 51
The number of used connections is 10% of the configured maximum.
You are using less than 10% of your configured max_connections.
Lowering max_connections could help to avoid an over-allocation of memory
See "MEMORY USAGE" section to make sure you are not over-allocating

INNODB STATUS
Current InnoDB index space = 240 K
Current InnoDB data space = 208 K
Current InnoDB buffer pool free = 82 %
Current innodb_buffer_pool_size = 8 M
Depending on how much space your innodb indexes take up it may be safe
to increase this value to up to 2 / 3 of total system memory

MEMORY USAGE
Max Memory Ever Allocated : 2.18 G
Configured Max Per-thread Buffers : 9.09 G
Configured Max Global Buffers : 1.25 G
Configured Max Memory Limit : 10.35 G
Physical Memory : 5.70 G

Max memory limit exceeds 90% of physical memory

KEY BUFFER
Current MyISAM index space = 236 M
Current key_buffer_size = 1.00 G
Key cache miss rate is 1 : 1936
Key buffer free ratio = 81 %
Your key_buffer_size seems to be fine

QUERY CACHE
Query cache is enabled
Current query_cache_size = 256 M
Current query_cache_used = 161 M
Current query_cache_limit = 32 M
Current Query cache Memory fill ratio = 63.25 %
Current query_cache_min_res_unit = 4 K
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 = 256 K
Sort buffer seems to be fine

JOINS
Current join_buffer_size = 16.00 M
You have had 24069 queries where a join could not use an index properly
join_buffer_size >= 4 M
This is not advised
You should enable "log-queries-not-using-indexes"
Then look for non indexed joins in the slow query log.

OPEN FILES LIMIT
Current open_files_limit = 9742 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_open_cache = 1024 tables
Current table_definition_cache = 256 tables
You have a total of 1621 tables
You have 1024 open tables.
Current table_cache hit rate is 1%
, while 100% of your table cache is in use
You should probably increase your table_cache
You should probably increase your table_definition_cache value.

TEMP TABLES
Current max_heap_table_size = 2.00 G
Current tmp_table_size = 2.00 G
Of 669537 temp tables, 37% were created on disk
Perhaps you should increase your tmp_table_size and/or max_heap_table_size
to reduce the number of disk-based temporary tables
Note! BLOB and TEXT columns are not allow in memory tables.
If you are using these columns raising these values might not impact your
ratio of on disk temp tables.

TABLE SCANS
Current read_buffer_size = 128 K
Current table scan ratio = 1179 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 1 : 3308
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'
Can anyone help me here please?
I don't know what to do. I am paying for dedicated and I can't use my server's resources.

Thank you

p.s. I am sorry for my English