gpt4 book ai didi

MySQL建议和调查

转载 作者:行者123 更新时间:2023-11-30 21:42:43 26 4
gpt4 key购买 nike

简介:我有一个带 SSD 和 512MB 内存(1024MB 突发)的 Debian 8 VPS,并且只将它与 MySQL 一起使用。我已经关闭了所有不必要的服务,并提供了数据库和系统上的所有资源。我只有 5 个工作站。 ping和网络稳定。

  1. 主要问题是,如果我像这样连续查询 10 次:
(SELECT IFNULL(SUM(Qtty), 0) FROM operations
WHERE blablabla
FROM (goods LEFT JOIN store ON goods.ID = store.GdID)
WHERE Deleted <> -1
GROUP BY goods.ID;

其中随机有 5-6 个执行了 2 秒,但其余的执行了 8 秒或更长时间!我认为没有理由出现这种行为。当我激活 slow_query_log 时,它只有相同的查询,没有别的。

  1. 我的 InnoDB 数据是 98MB 是否有任何理由为 innodb_buffer_pool_size 提供更多 RAM 或 128 就足够了?
  2. innodb_log_file_size 必须为 25% - 50%,哪个大小更适合我?
  3. tmp 目录是 tmpfs,所以如果 tmp_table_size 放在那里,是否有任何理由给它更多的 RAM 或者足以使用 1M 例如?
  4. table_open_cache - 我有大约 200 个表,是否有任何理由将其设为 20000,例如 mysqltuner 建议我?
  5. 我可以调整其他东西吗?

我的.cnf

skip-external-locking
skip-name-resolve
performance_schema = OFF
thread_stack = 192K
thread_cache_size = 10 #this is managed globally and is equal to max_connections
max_connections = 10
max_connect_errors = 10
connect_timeout = 20
wait_timeout = 20
interactive_timeout = 20
sql_mode = TRADITIONAL
default_storage_engine = InnoDB
innodb_buffer_pool_instances = 1
innodb_buffer_pool_size = 250M
innodb_log_file_size = 100M
innodb_strict_mode = ON
innodb_flush_method = O_DIRECT
innodb_flush_neighbors = 0
innodb_read_io_threads = 4
innodb_write_io_threads = 4
innodb_io_capacity = 2000
innodb_io_capacity_max = 3000
key_buffer = 128K
delay_key_write = ON
tmp_table_size = 10M # 32M = 53% temp
max_heap_table_size = 10M
query_cache_type = 0
query_cache_size = 0
table_open_cache = 5000
table_definition_cache = 3000

最佳答案

关于 my.cnf [mysqld] 部分的建议

max_connections=20  # from 10 to affect thread_cache_size  

.因为 MySQL 使用的 8 个线程 + 5 个并发 = 13,你会有一些额外的,拜托

tmp_table_size=16M  # from 10M   to reduce 41% temp tables created on disk
max_heap_table_size=16M # from 10M should always be = tmp_table_size
innodb_read_io_threads=64 # from 4 to let the ponies run
innodb_write_io_threads=64 # from 4 to push on through

如需更多帮助,请查看我的个人资料,点击网络个人资料以获取联系信息。

关于MySQL建议和调查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50845475/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com