如果表中有太多的列,是否会降低性能? [英] Is there a performance decrease if there are too many columns in a table?

查看:119
本文介绍了如果表中有太多的列,是否会降低性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的数据库中的一个表有大量的列,是否有一些性能损失?让我们假设我有一个有30列的表。

Is there some performance loss if one of tables in my database has huge amount of columns? Let's say I have a table with 30 columns.

我应该考虑将表分成几个更小的表还是确定?

Should I consider splitting the table into few smaller ones or is it ok?

每个数据库表的建议最大列数是多少?

What is a recommended maximum amount of columns per database table?

谢谢。

推荐答案

如果你真的需要所有这些列(即,它不只是一个标志,你有一个设计不好的表),然后通过一切手段保持它们。

If you really need all those columns (that is, it's not just a sign that you have a poorly designed table) then by all means keep them.

这不是一个性能问题,只要你

It's not a performance problem, as long as you


  • 在需要用来选择行的列上使用适当的索引

如果您有30,甚至200列,这对数据库没有问题。

If you have 30, or even 200 columns it's no problem to the database. You're just making it work a little harder if you want to retrieve all those columns at once.

拥有大量列的情况下,一个坏的代码气味;我不能想到任何合理的理由一个精心设计的表将有这么多列,你可能会改为需要一个其他的,更简单的表一对多的关系。

But having a lot of columns is a bad code smell; I can't think of any legitimate reason a well-designed table would have this many columns and you may instead be needing a one-many relationship with some other, much simpler, table.

这篇关于如果表中有太多的列,是否会降低性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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