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

查看:68
本文介绍了缩短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:

.... oft报告的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天全站免登陆