SQL INSERT 性能省略字段名称? [英] SQL INSERT performance omitting field names?
问题描述
有谁知道从 INSERT 查询中删除字段名称是否会带来一些性能改进?
Does anyone knows if removing the field names from an INSERT query results in some performance improvements?
我的意思是:
INSERT INTO table1 VALUES (value1, value2, ...)
更快地完成数据库而不是这样做:
faster for DB to be accomplished rather than doing this:
INSERT INTO table1 (field1, field2, ...) VALUES (value1, value2, ...)
?
我知道这可能是无意义的性能差异,但只是想知道.
I know it might be probably a meaningless performance difference, but just to know.
我通常使用 MySQL 和 PostgreSQL 作为数据库.
I'm usually using MySQL and PostgreSQL as DBs.
推荐答案
不,实际上恰恰相反! 至少对于 Microsoft SQL Server - 您没有指定您正在谈论的数据库.....
No, actually the contrary! At least for Microsoft SQL Server - you didn't specify what database you're talking about.....
如果您没有在 SELECT 或 INSERT 中指定字段,那么 SQL Server 的查询处理器必须首先检查系统目录以找出哪些字段确实可用.
If you don't specify the fields, either in a SELECT or an INSERT, then SQL Server's query processor must first go inspect the system catalogs to find out what fields are indeed available.
所以我总是建议明确列出你想要的字段 - 在 SELECT 和 INSERT 上一样多.
So I would always recommend to explicitly list the fields you want - on SELECTs as much as on INSERTs.
这篇关于SQL INSERT 性能省略字段名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!