影响表创建持续时间的Mysql参数

发布于 2025-01-07 22:47:21 字数 307 浏览 1 评论 0原文

我正在从 mysql 终端运行查询:

CREATE TABLE test(ID int, col1 id, col2 ID, PRIMARY KEY (ID) ENGINE = InnoDB;

使用 SHOW PROFILE 命令我得到平均:

创建表持续时间 = 0.008000,相当于大约 8 毫秒。

有什么建议可以在 mysql 配置中查看哪些参数来缩短表创建时间? 换句话说,哪些参数可以影响表创建时间。

我使用的是 Intel Xeon 3.80GHz 和 4Gb 内存。

I am running a query from mysql terminal:

CREATE TABLE test(ID int, col1 id, col2 ID, PRIMARY KEY (ID) ENGINE = InnoDB;

Using the SHOW PROFILE command I get an average of :

creating table duration = 0.008000 which equals to about 8ms.

Any suggestions what parameters to look in mysql configuration to improve table creation time?
In other words what parameters can affect the table creation time.

I am using a Intel Xeon 3.80GHz with 4Gb ram.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

你在我安 2025-01-14 22:47:21

以下是一些可能影响 CREATE TABLE 性能的变量:

  • 硬件 i/o
  • 文件系统
  • mysql 版本
  • ram
  • 数据库引擎类型(innodb / myisam / ...)
  • 表设计(键、字段等) .)
  • 与数据库的连接
  • 以及一些其他数据库服务器配置

总而言之,我认为 8 毫秒是可以的,但这是在不了解更多细节的情况下说的。

Here are some variables which might affect the CREATE TABLE-performance:

  • hardware i/o
  • file system
  • mysql version
  • ram
  • database engine type (innodb / myisam / ...)
  • table design (keys, fields, ...)
  • connection to the database
  • a few other database server configurations

All in all I'd say 8ms are ok, but thats said without knowing more details.

小巷里的女流氓 2025-01-14 22:47:21

据我所知,在软件方面没有太多可以专门配置表创建的功能。硬件可能会有所帮助,如果可以的话,首先添加更多 RAM。但是,之前有一个堆栈问题可能会导致提供一些帮助。

As far as I know there is not much on the software side you can configure for table creation specifically. Hardware may help, start by adding more RAM if you can. However, there was a previous Stack question that may lend some assistance.

っ左 2025-01-14 22:47:21

大多数参数取决于您使用的数据库引擎。假设它是 InnoDB(默认),请看一下 innodb_buffer_pool_sizeinnodb_additional_mem_pool_size

话虽如此,我怀疑您能否在 8 毫秒的基础上看到如此大的改进。

Most of the parameters will depend on the database engine you are using. Assuming its InnoDB (the default), take a look at innodb_buffer_pool_size and innodb_additional_mem_pool_size

That being said, I doubt you will be able to see that much improvement off of 8 ms.

靑春怀旧 2025-01-14 22:47:21

如果创建表需要 8 毫秒对您来说是个问题,那么您的数据库设计很可能有问题(如果您想每秒创建一千个表,就会出现这种情况)。

如果您只是临时使用它们,请使用存储在内存中的表:

CREATE TABLE test(ID int, col1 id, col2 ID, 
PRIMARY KEY (ID))
ENGINE=MEMORY;

创建速度会更快,但是如果您的服务器崩溃,那么这些表中的数据就会丢失。

If it's a problem for you that a table creation requires 8 milliseconds then there is quite likely something wrong with your database design (that would be the case if you want to create a thousand tables per second).

If you are using them just temporary, use tables that are stored in memory:

CREATE TABLE test(ID int, col1 id, col2 ID, 
PRIMARY KEY (ID))
ENGINE=MEMORY;

Creation will be faster, however if your server crashes then the data in those tables is lost.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文