如果表中有太多的列,是否会降低性能?

编程入门 行业动态 更新时间:2024-10-11 11:17:25
本文介绍了如果表中有太多的列,是否会降低性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如果我的数据库中的一个表有大量的列,是否有一些性能损失?让我们假设我有一个有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.

更多推荐

如果表中有太多的列,是否会降低性能?

本文发布于:2023-10-18 15:44:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1504657.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:太多   中有   是否会   性能

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!