English 中文(简体)
在MongoDB中存储DateTime对性能的影响
原标题:Storing DateTime in MongoDB effects on performance

我们正在讨论如何在MongoDB中存储日期。我对Mongo还很陌生,所以当我在文档中看到以下内容时(http://api.mongodb.org/perl/MongoDB/DataTypes.html#Dates)我想知道:

Warning: creating DateTime objects is extremely slow. Consider saving dates as numbers and converting the numbers to DateTimes when needed. A single DateTime field can make deserialization up to 10 times slower.

如果我们只是存储它们,并让它们对存储中的对象进行查询,这是一回事,但如果我们对这些字段进行过滤或排序,那似乎是另一回事。问题是从数字到DateTime的来回转换。欢迎对性能考虑进行任何思考。谢谢

最佳回答

Internally both datetime and long are stored as 64 bit ints per bsonspec http://bsonspec.org/#/specification. So there not be an additional perf penalty due to the cast from a server perspective. the problem is with the slowness of DateTime in perl. Note: use datetime or long consistently as one will not match the other.

问题回答

在本次谈话的其他地方提到,但值得总结:

所讨论的性能问题纯粹是一个Perl问题,并且与用Perl创建DateTime对象的成本有关。它与一般MongoDB的性能无关,也与Perl以外语言的MongoDB驱动程序无关。C#驱动程序应该不会出现DateTimes的性能问题。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签