缩短 MongoDB 属性名称是否值得? [英] Is shortening MongoDB property names worthwhile?

查看:31
本文介绍了缩短 MongoDB 属性名称是否值得?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

博客滚动使用 mongoDB、express 和 Node.js 中,作者提到缩短属性名称:

In Blog rolling with mongoDB, express and Node.js the author mentions it's a good idea to shorten property names:

....mongoDB 经常报告的问题是磁盘上数据的大小......每条记录都存储所有字段名称.... 这意味着它通常可以拥有诸如t"或b"之类的属性更节省空间比标题"或正文",但由于害怕混淆,我会避免除非确实需要这样做!

....oft-reported issue with mongoDB is the size of the data on the disk... each and every record stores all the field-names .... This means that it can often be more space-efficient to have properties such as 't', or 'b' rather than 'title' or 'body', however for fear of confusion I would avoid this unless truly required!

我知道如何做到这一点的解决方案.我更感兴趣的是什么时候真正需要这样做?

I am aware of solutions of how to do it. I am more interested in when is this truly required?

推荐答案

引用Donald Knuth:

过早的优化是万恶之源(或至少大部分它)在编程中.

Premature optimization is the root of all evil (or at least most of it) in programming.

然而,构建您的应用程序似乎是最明智、可维护和合乎逻辑的.然后,如果您遇到性能或存储问题,请处理影响最大的问题,直到性能令人满意或收益递减规律意味着进一步优化没有意义.

Build your application however seems most sensible, maintainable and logical. Then, if you have performance or storage issues, deal with those that have the greatest impact until either performance is satisfactory or the law of diminishing returns means there's no point in optimising further.

如果您不确定特定设计决策(例如长属性名称)的影响,请创建一个原型来测试各种假设(例如较短的属性名称会节省多少空间").不要指望测试的结果是决定性的,但它可能会教给你意想不到的东西.

If you are uncertain of the impact of particular design decisions (like long property names), create a prototype to test various hypotheses (like "will shorter property names save much space"). Don't expect the outcome of testing to be conclusive, however it may teach you things you didn't expect to learn.

这篇关于缩短 MongoDB 属性名称是否值得?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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