mysql 插入 &更新优化

发布于 2024-09-04 14:54:54 字数 291 浏览 1 评论 0原文

这主要是一个优化问题。 我的网站上有许多表单可以执行简单的插入和更新。 (没什么复杂的)

但是,表单的几个输入字段不是必需的,可以留空。 (同样,没什么复杂的)

但是,我的 SQL 查询将包含语句中的所有列。 我的问题是,最好适当优化插入/更新查询吗?并且只将更改的列应用到查询中?

我们都听说我们不应该使用“SELECT *”查询,除非它绝对需要显示所有列。 但是插入和插入呢?更新?

希望这是有道理的。

我确信任何数量的优化都是可以接受的。但我从来没有真正从任何人那里听说过这件事。

This is an optimization question, mostly.
I have many forms on my sites that do simple Inserts and Updates. (Nothing complicated)

But, several of the form's input fields are not necessary and may be left empty. (again, nothing complicated)

However, my SQL query will have all columns in the Statement.
My question, is it best to optimize the Inserts/Update queries appropriately? And only apply the columns that are changed into the query?

We all hear that we shouldn't use the "SELECT *" query, unless it's absolutely needed for displaying all columns.
But what about Inserts & Updates?

Hope this makes sense.

I'm sure any amount of optimization is acceptable. But I never really hear about this, specifically, from anyone.

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

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

发布评论

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

评论(1

请叫√我孤独 2024-09-11 14:54:54

如果插入/更新的任何列上有索引,插入和更新都会受到影响,因此必须做出妥协 - 表的读取量是否大于添加/更新的量,反之亦然?

假设您没有使用参数化存储过程来执行这些任务,则 SQL 语句的文本越短 - 它到达服务器和服务器的速度就越快。然后被处决。

Inserts and updates will be impacted if there are indexes on any of the columns being inserted/updated, so it's a compromise that has to be struck - is the table read more than it's add to/updated, or vice versa?

Assuming you aren't using parameterized stored procedures to perform these tasks, the shorter the text is for the SQL statement - the faster it should get to the server & then be executed.

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