这张桌子应该分成两部分吗?

发布于 2024-10-28 17:45:16 字数 65 浏览 2 评论 0原文

我有一个有 11 列的表,现在大多数情况下该表上的三列都是空的,但如果我分成两列,每个表会有更多查询。你的建议是什么

I have a table which has 11 columns, now most of the time three columns on this table will be empty, but then if I split in two, there are more queries per table. Whats your suggestions

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

日久见人心 2024-11-04 17:45:16

还有许多其他变量需要考虑。我想到的是:

  • 桌子有多大?
  • 通常为空的三列有多大?
  • 哪些类型的查询使用该表?
  • 列中的数据是什么类型?例如,如果它属于查找表中,那么避免重复数据可能是有意义的。这不一定与问题密切相关,但值得考虑。
  • 这些字段是否已建立索引(或在任何索引中使用)?如果是这样,它可能会增加 INSERTS 和 DELETES 的成本(如果它们是空的并且在 UPDATE 操作期间保持不变,则不会增加那么多)。

但总的来说,我认为将其保留为单个表是可以的。 11 列并不算多。因此,除非表非常大(相对而言)并且空间非常宝贵,否则单个表的简单性是一个好主意,特别是当数据逻辑上属于表时。

There are a number of other variables to take into account. Some that come to mind are:

  • How large is the table?
  • How big are the three columns that are usually empty?
  • What types of queries use the table?
  • What type of data is in the columns? For example, if it is something that belongs in a lookup table, then it may make sense to avoid duplicating data. This one isn't necessarily germane to the question but is worth considering.
  • Are the fields indexed (or used in any indexes)? If so, it would probably increase the cost of INSERTS and DELETES (not so much if they are empty and left unchanged during UPDATE operations).

In general, though, I would say that leaving it as a single table is okay. 11 columns are not that many. So unless the table is really large (a relative term) and space is at a premium, the simplicity of a single table is a good idea particularly if the data logically belongs in the table.

逆夏时光 2024-11-04 17:45:16

如果您主要关心的是速度,那么将表放在一起将为您提供更便宜的 SELECT 查询,因为您不需要 JOIN。

If your primary concern is speed, then keeping the table together would grant you less expensive SELECT queries since you won't meed to JOIN.

べ繥欢鉨o。 2024-11-04 17:45:16

就我个人而言,我认为对于 11 列,无论哪种方式,您的性能提升都将是最小的。我认为目前这更多是个人喜好。

Personally, I think with 11 columns, your performance gains will be minimal either way. I think it's more personal preference at this point.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文