|
Долго выполняется запрос
|
|||
---|---|---|---|
#18+
Здравствуйте, Тестирую сайт с базой данных размером 1,5 Гб на облачном VDS сервере (Процессорных ядер: 2, Память: 2 Гб, SSD) и один из запросов выполняется очень долго (1,5 с). Код: sql 1.
Настройки делал по mysqltuner.pl. Сейчас его работа выглядит так: mysqltuner >> MySQLTuner 1.7.19 - Major Hayden <major@mhtx.net> >> 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] Logged in using credentials from Debian maintenance account. [OK] Currently running supported MySQL version 10.3.18-MariaDB-1:10.3.18+maria~stretch-log [OK] Operating on 64-bit architecture -------- Log file Recommendations ------------------------------------------------------------------ [OK] Log file /var/log/mysql/mariadb-error.log exists [--] Log file: /var/log/mysql/mariadb-error.log(105K) [OK] Log file /var/log/mysql/mariadb-error.log is readable. [OK] Log file /var/log/mysql/mariadb-error.log is not empty [OK] Log file /var/log/mysql/mariadb-error.log is smaller than 32 Mb [!!] /var/log/mysql/mariadb-error.log contains 848 warning(s). [!!] /var/log/mysql/mariadb-error.log contains 12 error(s). [--] 9 start(s) detected in /var/log/mysql/mariadb-error.log [--] 1) 2019-11-21 9:29:46 0 [Note] /usr/sbin/mysqld: ready for connections. [--] 2) 2019-11-21 9:21:51 0 [Note] /usr/sbin/mysqld: ready for connections. [--] 3) 2019-11-21 9:11:21 0 [Note] /usr/sbin/mysqld: ready for connections. [--] 4) 2019-11-20 14:10:39 0 [Note] /usr/sbin/mysqld: ready for connections. [--] 5) 2019-11-20 14:08:24 0 [Note] /usr/sbin/mysqld: ready for connections. [--] 6) 2019-11-20 13:03:03 0 [Note] /usr/sbin/mysqld: ready for connections. [--] 7) 2019-11-20 11:30:56 0 [Note] /usr/sbin/mysqld: ready for connections. [--] 8) 2019-11-20 10:46:05 0 [Note] /usr/sbin/mysqld: ready for connections. [--] 9) 2019-11-15 9:32:50 0 [Note] /usr/sbin/mysqld: ready for connections. [--] 8 shutdown(s) detected in /var/log/mysql/mariadb-error.log [--] 1) 2019-11-21 9:29:45 0 [Note] /usr/sbin/mysqld: Shutdown complete [--] 2) 2019-11-21 9:21:50 0 [Note] /usr/sbin/mysqld: Shutdown complete [--] 3) 2019-11-21 9:11:20 0 [Note] /usr/sbin/mysqld: Shutdown complete [--] 4) 2019-11-20 14:10:38 0 [Note] /usr/sbin/mysqld: Shutdown complete [--] 5) 2019-11-20 14:08:23 0 [Note] /usr/sbin/mysqld: Shutdown complete [--] 6) 2019-11-20 13:03:02 0 [Note] /usr/sbin/mysqld: Shutdown complete [--] 7) 2019-11-20 11:30:55 0 [Note] /usr/sbin/mysqld: Shutdown complete [--] 8) 2019-11-19 20:06:35 0 [Note] /usr/sbin/mysqld: Shutdown complete -------- Storage Engine Statistics ----------------------------------------------------------------- [--] Status: +Aria +CSV +InnoDB +MEMORY +MRG_MyISAM +MyISAM +PERFORMANCE_SCHEMA +SEQUENCE [--] Data in InnoDB tables: 152.6M (Tables: 3) [--] Data in MyISAM tables: 2.0G (Tables: 184) [OK] Total fragmented tables: 0 -------- Analysis Performance Metrics -------------------------------------------------------------- [--] innodb_stats_on_metadata: OFF [OK] No stat updates during querying INFORMATION_SCHEMA. -------- Security Recommendations ------------------------------------------------------------------ [OK] There are no anonymous accounts for any database users [OK] All database users have passwords assigned [!!] There is no basic password file list! -------- CVE Security Recommendations -------------------------------------------------------------- [--] Skipped due to --cvefile option undefined -------- Performance Metrics ----------------------------------------------------------------------- [--] Up for: 12m 52s (67 q [0.087 qps], 41 conn, TX: 184K, RX: 10K) [--] Reads / Writes: 100% / 0% [--] Binary logging is disabled [--] Physical Memory : 2.0G [--] Max MySQL memory : 6.5G [--] Other process memory: 0B [--] Total buffers: 1.5G global + 51.2M per thread (100 max threads) [--] P_S Max memory usage: 0B [--] Galera GCache Max memory usage: 0B [OK] Maximum reached memory usage: 1.5G (76.86% of installed RAM) [!!] Maximum possible memory usage: 6.5G (326.86% of installed RAM) [!!] Overall possible memory usage with other process exceeded memory [OK] Slow queries: 0% (0/67) [OK] Highest usage of available connections: 1% (1/100) [OK] Aborted connections: 0.00% (0/41) [!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance [!!] Query cache may be disabled by default due to mutex contention. [!!] Query cache efficiency: 0.0% (0 cached / 18 selects) [OK] Query cache prunes per day: 0 [OK] Sorts requiring temporary tables: 0% (0 temp sorts / 2 sorts) [OK] No joins without indexes [OK] Temporary tables created on disk: 0% (0 on disk / 23 total) [OK] Thread cache hit rate: 95% (2 created / 41 connections) [OK] Table cache hit rate: 97% (270 open / 276 opened) [OK] table_definition_cache(400) is upper than number of tables(346) [OK] Open file limit used: 2% (428/16K) [OK] Table locks acquired immediately: 100% (22 immediate / 22 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: 2 thread(s). [--] Using default value is good enough for your version (10.3.18-MariaDB-1:10.3.18+maria~stretch-log) -------- MyISAM Metrics ---------------------------------------------------------------------------- [!!] Key buffer used: 18.3% (191M used / 1B cache) [OK] Key buffer size / total MyISAM indexes: 1000.0M/823.7M [!!] Read Key buffer hit rate: 80.0% (10 cached / 2 reads) -------- InnoDB Metrics ---------------------------------------------------------------------------- [--] InnoDB is enabled. [--] InnoDB Thread Concurrency: 0 [OK] InnoDB File per table is activated [OK] InnoDB buffer pool / data size: 256.0M/152.6M [!!] Ratio InnoDB log file size / InnoDB Buffer pool size (37.5 %): 48.0M * 2/256.0M should be equal to 25% [OK] InnoDB buffer pool instances: 1 [--] Number of InnoDB Buffer Pool Chunk : 2 for 1 Buffer Pool Instance(s) [OK] Innodb_buffer_pool_size aligned with Innodb_buffer_pool_chunk_size & Innodb_buffer_pool_instances [OK] InnoDB Read buffer efficiency: 99.21% (552472 hits/ 556885 total) [!!] InnoDB Write Log efficiency: 0% (1 hits/ 0 total) [OK] InnoDB log waits: 0.00% (0 waits / 1 writes) -------- AriaDB Metrics ---------------------------------------------------------------------------- [--] AriaDB is enabled. [OK] Aria pagecache size / total Aria indexes: 64.0M/1B -------- TokuDB Metrics ---------------------------------------------------------------------------- [--] TokuDB is disabled. -------- XtraDB Metrics ---------------------------------------------------------------------------- [--] XtraDB is disabled. -------- Galera Metrics ---------------------------------------------------------------------------- [--] Galera is disabled. -------- Replication Metrics ----------------------------------------------------------------------- [--] Galera Synchronous replication: NO [--] No replication slave(s) for this server. [--] Binlog format: MIXED [--] XA support enabled: ON [--] Semi synchronous replication Master: OFF [--] Semi synchronous replication Slave: OFF [--] This is a standalone server -------- Recommendations --------------------------------------------------------------------------- General recommendations: Control warning line(s) into /var/log/mysql/mariadb-error.log file Control error line(s) into /var/log/mysql/mariadb-error.log file MySQL was started within the last 24 hours - recommendations may be inaccurate Reduce your overall MySQL memory footprint for system stability Dedicate this server to your database for highest performance. Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1 Performance schema should be activated for better diagnostics Consider installing Sys schema from https://github.com/mysql/mysql-sys for MySQL Consider installing Sys schema from https://github.com/good-dba/mariadb-sys for MariaDB Before changing innodb_log_file_size and/or innodb_log_files_in_group read this: https://bit.ly/2TcGgtU Variables to adjust: *** MySQL's maximum memory usage is dangerously high *** *** Add RAM before increasing MySQL buffer variables *** query_cache_size (=0) query_cache_type (=0) query_cache_limit (> 100M, or use smaller result sets) performance_schema = ON enable PFS innodb_log_file_size should be (=32M) if possible, so InnoDB total log files size equals to 25% of buffer pool size. Подскажите, на что обратить внимание, чтобы улучшить скорость выполнения запроса? ... |
|||
:
Нравится:
Не нравится:
|
|||
21.11.2019, 10:06 |
|
Долго выполняется запрос
|
|||
---|---|---|---|
#18+
Russ86, Покажите план запроса и DDL всех участвующих таблиц. ... |
|||
:
Нравится:
Не нравится:
|
|||
21.11.2019, 10:29 |
|
Долго выполняется запрос
|
|||
---|---|---|---|
#18+
miksoft, более подробная информация: Сам запрос в более читабельном виде: Код: sql 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27.
JSON explain { "query_block": { "select_id": 1, "table": { "table_name": "b", "access_type": "const", "possible_keys": ["PRIMARY"], "key": "PRIMARY", "key_length": "4", "used_key_parts": ["block_id"], "ref": ["const"], "rows": 1, "filtered": 100 }, "table": { "table_name": "d", "access_type": "const", "possible_keys": ["PRIMARY"], "key": "PRIMARY", "key_length": "10", "used_key_parts": ["block_id", "lang_code"], "ref": ["const", "const"], "rows": 1, "filtered": 100 }, "table": { "table_name": "c", "access_type": "range", "possible_keys": ["PRIMARY", "idx_object_id_snapping_id"], "key": "PRIMARY", "key_length": "4", "used_key_parts": ["block_id"], "rows": 166716, "filtered": 0.0834, "attached_condition": "c.block_id = 152 and c.lang_code = 'ru' and (c.object_id = 301215 and c.object_type like 'products' or c.object_id = 0 and c.object_type like '')" } } } Ранее сайт располагался на своем сервере, запросы выполнялись быстро, а на VDS проблемы со скоростью. Не уверен, что это из-за характеристик сервера, возможно что-то не так с настройками. ... |
|||
:
Нравится:
Не нравится:
|
|||
21.11.2019, 11:05 |
|
Долго выполняется запрос
|
|||
---|---|---|---|
#18+
DDL участвующих таблиц Код: sql 1. 2. 3. 4. 5. 6. 7.
Код: sql 1. 2. 3. 4. 5. 6.
Код: sql 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.
... |
|||
:
Нравится:
Не нравится:
|
|||
21.11.2019, 11:20 |
|
|
start [/forum/topic.php?fid=47&fpage=28&tid=1828851]: |
0ms |
get settings: |
7ms |
get forum list: |
12ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
62ms |
get topic data: |
13ms |
get forum data: |
2ms |
get page messages: |
46ms |
get tp. blocked users: |
2ms |
others: | 21ms |
total: | 171ms |
0 / 0 |