Jump to content
Sign in to follow this  

Сайт тормозит. Сисадмин сказал "индексов нету на запросы с join"

Recommended Posts

Вот что выдаёт утилита mysqltuner.pl:


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

[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.5.52-MariaDB
[OK] Operating on 64-bit architecture

-------- Log file Recommendations ------------------------------------------------------------------
[--] Log file: /var/log/mariadb/mariadb.log(337K)
[OK] Log file /var/log/mariadb/mariadb.log exists
[OK] Log file /var/log/mariadb/mariadb.log is readable.
[OK] Log file /var/log/mariadb/mariadb.log is not empty
[OK] Log file /var/log/mariadb/mariadb.log is smaller than 32 Mb
[!!] /var/log/mariadb/mariadb.log contains 528 warning(s).
[!!] /var/log/mariadb/mariadb.log contains 661 error(s).
[--] 141 start(s) detected in /var/log/mariadb/mariadb.log
[--] 1) 170528 11:17:09 [Note] /usr/libexec/mysqld: ready for connections.
[--] 2) 170528  7:14:00 [Note] /usr/libexec/mysqld: ready for connections.
[--] 3) 170527 20:20:29 [Note] /usr/libexec/mysqld: ready for connections.
[--] 4) 170527 20:11:58 [Note] /usr/libexec/mysqld: ready for connections.
[--] 5) 170527 19:18:24 [Note] /usr/libexec/mysqld: ready for connections.
[--] 6) 170527 19:11:30 [Note] /usr/libexec/mysqld: ready for connections.
[--] 7) 170527 19:08:27 [Note] /usr/libexec/mysqld: ready for connections.
[--] 8) 170527 18:47:52 [Note] /usr/libexec/mysqld: ready for connections.
[--] 9) 170527 14:55:48 [Note] /usr/libexec/mysqld: ready for connections.
[--] 10) 170527 14:13:27 [Note] /usr/libexec/mysqld: ready for connections.
[--] 48 shutdown(s) detected in /var/log/mariadb/mariadb.log
[--] 1) 170528 11:16:41 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 2) 170528  7:13:32 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 3) 170527 19:11:07 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 4) 170527 19:08:26 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 5) 170527 14:55:46 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 6) 170527 14:02:45 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 7) 170527 14:02:08 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 8) 170527 14:01:34 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 9) 170527 13:26:56 [Note] /usr/libexec/mysqld: Shutdown complete
[--] 10) 170527 13:21:39 [Note] /usr/libexec/mysqld: Shutdown complete

-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Data in MyISAM tables: 36M (Tables: 566)
[--] Data in InnoDB tables: 1M (Tables: 64)
[OK] Total fragmented tables: 0

-------- Security Recommendations ------------------------------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[!!] User '[email protected]%' hasn't specific host restriction.
[!!] User '[email protected]%' hasn't specific host restriction.
[!!] There is no basic password file list!

-------- CVE Security Recommendations --------------------------------------------------------------
[--] Skipped due to --cvefile option undefined

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 2d 12h 17m 6s (6M q [31.764 qps], 19K conn, TX: 27G, RX: 6G)
[--] Reads / Writes: 99% / 1%
[--] Binary logging is disabled
[--] Physical Memory     : 3.9G
[--] Max MySQL memory    : 3.2G
[--] Other process memory: 815.5M
[--] Total buffers: 640.0M global + 8.8M per thread (300 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[OK] Maximum reached memory usage: 736.6M (18.64% of installed RAM)
[OK] Maximum possible memory usage: 3.2G (82.85% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (0/6M)
[OK] Highest usage of available connections: 3% (11/300)
[OK] Aborted connections: 1.15%  (223/19313)
[--] Skipped name resolution test due to skip_networking=ON in system variables.
[OK] Query cache is disabled by default due to mutex contention on multiprocessor machines.
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 7M sorts)
[!!] Joins performed without indexes: 66346
[OK] Temporary tables created on disk: 18% (241K on disk / 1M total)
[OK] Thread cache hit rate: 99% (11 created / 19K connections)
[OK] Table cache hit rate: 47% (1K open / 2K opened)
[OK] Open file limit used: 37% (1K/4K)
[OK] Table locks acquired immediately: 99% (48M immediate / 48M locks)

-------- Performance schema ------------------------------------------------------------------------
[--] Performance schema is disabled.
[--] Memory used by P_S: 0B
[--] Sys schema isn't installed.

-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is enabled.
[--] Thread Pool Size: 1 thread(s).
[--] Using default value is good enough for your version (5.5.52-MariaDB)

-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 20.3% (85M used / 419M cache)
[OK] Key buffer size / total MyISAM indexes: 400.0M/8.0M
[OK] Read Key buffer hit rate: 100.0% (24B cached / 6K reads)
[OK] Write Key buffer hit rate: 100.0% (46 cached / 46 writes)

-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[OK] InnoDB buffer pool / data size: 32.0M/1.7M
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (31.25 %): 5.0M * 2/32.0M should be equal 25%
[OK] InnoDB buffer pool instances: 1
[--] InnoDB Buffer Pool Chunk Size not used or defined in your version
[OK] InnoDB Read buffer efficiency: 99.94% (1807937 hits/ 1809008 total)
[!!] InnoDB Write Log efficiency: 69.2% (12515 hits/ 18085 total)
[OK] InnoDB log waits: 0.00% (0 waits / 5570 writes)

-------- AriaDB Metrics ----------------------------------------------------------------------------
[--] AriaDB is enabled.
[OK] Aria pagecache size / total Aria indexes: 128.0M/1B
[!!] Aria pagecache hit rate: 93.4% (3M cached / 240K reads)

-------- TokuDB Metrics ----------------------------------------------------------------------------
[--] TokuDB is disabled.

-------- XtraDB Metrics ----------------------------------------------------------------------------
[--] XtraDB is disabled.

-------- RocksDB Metrics ---------------------------------------------------------------------------
[--] RocksDB is disabled.

-------- Spider Metrics ----------------------------------------------------------------------------
[--] Spider is disabled.

-------- Connect Metrics ---------------------------------------------------------------------------
[--] Connect is disabled.

-------- Galera Metrics ----------------------------------------------------------------------------
[--] Galera is disabled.

-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] This is a standalone server.

-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    Control warning line(s) into /var/log/mariadb/mariadb.log file
    Control error line(s) into /var/log/mariadb/mariadb.log file
    Restrict Host for [email protected]% to [email protected]
    Dedicate this server to your database for highest performance.
    Enable the slow query log to troubleshoot bad queries
    Adjust your join queries to always utilize indexes
    Performance shouldn't be activated for MySQL and MariaDB 5.5 and lower version
    Consider installing Sys schema from https://github.com/mysql/mysql-sys
Variables to adjust:
    join_buffer_size (> 512.0K, or always use indexes with joins)
    performance_schema = OFF disable PFS
    innodb_log_file_size * innodb_log_files_in_group should be equal to 1/4 of buffer pool size (=16M) if possible.



Что это означает? Какую задачу ставить программисту?

Share this post

Link to post
Share on other sites

Ну так пусть добавит

Share this post

Link to post
Share on other sites

В ТЗ что писать непонятно. Эти "индексы" наверное автоматом должны создаваться, а не вручную добавляться?

Edited by SFS77

Share this post

Link to post
Share on other sites

Вам кто-то сказал, что нет индексов

есть сисадмин

есть sysdba

есть программер - который ни в зуб ногой в этих логах


Share this post

Link to post
Share on other sites
55 минут назад, SFS77 сказал:

Эти "индексы" наверное автоматом должны создаваться, а не вручную добавляться?

Нет. Точно так же, как таблицы не создаются автоматом, а только если в инсталяторе есть для этого соответствующий SQL, так и индексы создаются только, если это прописано (а прописано далеко не все). А иначе надо их добавлять самостоятельно.

И нехватка индексов - это классическая беда ОК, из-за которой он уже на нескольких тысячах товаров начинает задыхаться.

  • +1 1

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.


Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.