使用 SELECT * 语句的生产性能? [英] Production Perfomance of using SELECT * statements?

查看:50
本文介绍了使用 SELECT * 语句的生产性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么在生产代码中使用 SELECT * 被认为是不好的做法?在生产中是否有其他选择,或者我们是否需要单独 SELECT 表中的每一列?

Why is the use of SELECT * in production code considered bad practice? Is there any alternative for using in production, or do we need to SELECT every column in the table individually?

推荐答案

使用 SELECT * 是一种不好的做法,原因有几个,至少在 SSIS 的上下文中是这样.

Using SELECT * is a bad practice for a few reasons, at least in the context of SSIS.

选择所有列,如果您不需要所有列,则是浪费内存,而内存是使 SSIS 运行快速(或不运行)的魔法.

Selecting all the columns, if you don't need all of them, is a waste of memory and memory is the magic that makes SSIS run fast (or not).

选择所有列(如果您不需要所有列)将阻止 SQL Server 使用索引更快地将数据返回给您.

Selecting all the columns, if you don't need all of them, will prevent SQL Server from using an index to return your data faster to you.

SSIS 是非常元数据驱动的.因此,如果您将 SELECT * 作为您的源,如果将列添加到表中,您的源定义已更改,并且您的包可能会因元数据不再一致而失败.

SSIS is very meta-data driven. Therefore, if you have SELECT * as your source, if a column is added to the table your source definition has changed and your package may fail as the metadata is no longer consistent.

这篇关于使用 SELECT * 语句的生产性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆