MySQL选择性能 [英] MySQL select performance

查看:45
本文介绍了MySQL选择性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
哪个更快/最好?SELECT * 或 SELECT column1、colum2、column3 等

我有一个关于 MySQL 性能的问题.在开始之前对不起我的英语不好.

I have a question about performance in MySQL. Before the start sorry for my bad English.

问题是:星号和逗号分隔的字段名称之间的性能差异是什么.

It's the question: what is performance differences between asterisk and field names in comma separated.

例如:a 有一个名为example_table"的表和 5 个字段f1、f2、f3、f4、f5".

For example: a have a table in "example_table" named and 5 fields "f1, f2, f3, f4, f5" named.

select * from `example_table`;

select f1, f2, f3, f4, f5 from `example_table`;

感谢回复.

推荐答案

如果您选择所有字段,则不会有可测量的性能差异.

If you select all fields there will be no measurable performance difference.

这提高了代码可读性,因为您确切知道查询将返回哪些字段.

This improves code readability, as you know exactly which fields the query will return.

如果您不选择所有字段,则第二种形式的性能会稍好一些,因为 MySQL 将在网络上发送较少的数据.

If you don't select all fields the second form will have a slightly better performance because MySQL will send less data on the network.

如果表包含 TEXT 或 BLOB 列并且您不询问这些列,这也可能导致较少的磁盘读取.这些类型不直接存储在行中,因此可以避免一些额外的磁盘读取.

This may also cause less disk reads if the table contains TEXT or BLOB columns and you don't ask these columns. These types are not stored directly in the rows, so this would avoid some extra disk reads.

不过,如果您选择所有字段,则不会有可衡量的性能差异.

There will be no measurable performance difference if you select all fields, though.

这篇关于MySQL选择性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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