Статьи

MongoDB 2.4 теперь доступна на всех планах MongoLab

Примечание куратора: содержание этой статьи изначально было написано Шоном в  блоге MongoLab. 

Привет, монгеры!

Команда MongoLab  очень рада  объявить, что версия 2.4 MongoDB теперь доступна для всех наших планов!

Вы можете спросить насчет текущих баз данных? На этой неделе пользователи получат электронное письмо, содержащее все, что им нужно знать о процессе обновления. Следите за своими почтовыми ящиками!

2.4 Основные моменты выпуска

Мы продвинулись вперед и выделили некоторые функции и изменения в 2.4, которые, по нашему мнению, наиболее вероятно будут полезны для  вас , наших пользователей. (Не за что!)   Полный список изменений в 2.4 см. В официальных примечаниях к выпуску . Основные моменты:

V8 JavaScript Engine

Вы правильно прочитали: движок JavaScript в версии 2.4 работает на большем количестве цилиндров. Это изменение затрагивает mapReducegroupи  eval команды, а также  $where оператор запроса. Основным преимуществом для пользователей является повышение производительности JavaScript, особенно если вам необходимо одновременно выполнять несколько операций JavaScript.

Для полной информации об изменениях JavaScript в версии 2.4 смотрите документ  здесь .

Новый геопространственный индекс и улучшенная сферическая геометрия

Если вы создаете приложение следующего убийцы с использованием служб определения местоположения, эти обновления для вас. Новый 2dsphere геопространственный индекс поддерживает улучшенные сферические запросы, а также поддержку следующих  объектов GeoJSON :

  • точка

  • LineString

  • многоугольник

2dsphere Индекс представляет 2 новых операторов запросов для запросов по данным GeoJSON:

  1. $geoWithin — используйте это для запроса точки, линии или фигуры, которая полностью содержится в другой фигуре. Этот оператор заменяет  $within оператора, который устарел с 2.4

  2. $geoIntersects — используйте это для запроса местоположений, которые пересекаются с объектом GeoJSON, включая объекты, которые имеют общий край

Полную информацию о геопространственных индексах и запросах можно найти  здесь .

Существует также отличный пост в блоге от 10gen, где обсуждаются эти новые гео-функции в 2.4  здесь .

Оператор нового обновления: $setOnInsert

Для использования с  {upsert : true} оператором новый  $setOnInsert оператор устанавливает поля в документе только тогда, когда  upsert операция выполняет вставку и ничего не делает при обновлении.

Подробности о том, как использовать этот новый оператор, можно найти  здесь .

New Array Update Modifiers

The $push operator for arrays has been updated to support 3 new modifiers that can be used to more precisely control how arrays are modified (e.g. sort or limit the size of an array after an update operation):

  • $each

  • $sort

  • $slice

Details on how to use these modifiers together to modify arrays can be found here.

If you tend you use arrays in your data model, our might be of interest to you.

Improved Performance on count() Operations

Count von Count‘s favorite MongoDB operation is now up to 20x faster for low cardinality index based counts! ”AH AH AH AH AH!”

Multiple Concurrent Index Builds

Prior to 2.4, only 1 background index per database could be built at a time. With 2.4 comes the ability to run multiple background index builds concurrently. Running index builds in the background can be done like so:

> db.collection.ensureIndex({index_field : 1}, {background : true})

As always, we recommend running index builds on large collections during off-peak times. Even though background index builds are non-blocking, they are still computationally expensive operations.

Full details on this feature can be found here.

User Uniqueness Enforced

Starting in 2.4, the system.users collection enforces uniqueness on the user field.

If one of your databases has two or more users with the same username but different passwords or read privileges, you should have received an email from us containing more details and the steps you need to take to avoid any potential downtime for your app when we upgrade you to 2.4. Don’t worry – you’ll receive plenty of advance notice about any automagical upgrades we do to 2.4 (namely free Sandbox plans, and for-pay Shared plans that are running 2.0).

New Metrics in db.serverStatus()

(Alright, this one is probably more interesting to us here at MongoLab, but if you’re one of those users who like to keep tabs on how well your database is performing, you might dig this new feature. For the rest of you, just know that this feature will help us serve you even better!)

A number of new metrics have been added to the output of the serverStatus command. One of particular interest is the new working set estimator:

  • working set estimator : the working set is the data that MongoDB uses actively. This metric will only be shown if explicitly enabled:

> db.serverStatus({workingSet : 1})

The working set section of the output looks like:

...
"workingSet" : {
    "note" : "thisIsAnEstimate",
    "pagesInMemory" : <num>,
    "computationTimeMicros" : <num>,
    "overSeconds" : <num>
}
...

There are a plethora of other new metrics in the new serverStatus.metrics subdocument output, too many to cover in this summary, but you can find complete details here.

Text Search (Beta)

New in 2.4 is the ability to do index-based searches on the contents of string values that have been indexed using the new text index feature.

Full documentation for the new text search feature can be found here.

The “awww, man?!?!” bit: because this is not yet GA (it is a beta feature in 2.4), it will only be available on databases created on our free Sandbox plans when you select the “experimental” checkbox. But at least you can play around with it in a Sandbox database to see if it’s something you will want to leverage in your app. Hopefully come 2.6 this awesome new feature will be out of beta and fully supported!

Questions?

As always, if you have any questions or thoughts please shoot us an email. We love to help!