What are the advantages of running NoSQL (ex MongoDB) over MySQL, PostGRE SQL or MSSQL in Drupal? Are the advantages gained from simply using the storage or does some Drupal configuration need to change?
MongoDB can be used to store most or all your entities into fast, document-oriented storage. This type of storage scales way better then the standard SQL based storage we have in Drupal core (which is based on a "one table per field" schema).
In the current state of Drupal 7, you would have:
- The base table of the entity stored on SQL (ie. the users table, the node table, etc.)
- All fields stored in SQL
- The properties of the entities from their base tables duplicated in MongoDB
This allows fast querying on the entities on MongoDB, and the ability to add complex indexes that no Opensource SQL database support (including indexes across tables). At the same time, you don't lose interoperability because the base table of the entity is still stored in SQL and can thus be joined by modules that are still SQL-only (like Flag).
This type of fast querying is available thanks to the EntityFieldQuery mechanism, a way to build queries on entities, their properties and their fields in an abstract manner. The default implementation in core translate those queries to SQL, but the MongoDB module has a full-featured implementation that can satisfy those queries from MongoDB directly.
Thanks to the EntityFieldQuery backend for Views, you can easily leverage this power, by using the tools you are used to. The only downside is that relationships are not supported (but in practice you rarely need them anyway - and this can be worked-around by pushing additional data into the entity object and add exposing them as additional properties of the entity).
In a nutshell, as soon as query performance is a problem on your project, which happens as soon as you have a significant dataset (let's say starting at a few tenth of thousands of entities on a given entity type), MongoDB is a net gain for very very few drawbacks. Highly recommended.
MongoDB and similar are designed to store structured (hierarchical) data in a relatively flexible way.
For example in
Drupal 7, when using
field_sql_storage, every field gets it's very own tables. When you attach 10 fields to a content type, you end up with 10 tables in your database. When you load that node,
field_sql_storage will execute a query per field and per node (or multiple nodes, when using
When you use mongodb_field_storage, you can store all fields of a node in a single document and get with a single query.
You can also store other things like watchdog, sessions, cache, blocks in MongoDB.
You still need MySQL however, MongoDB doesn't replace it (only for specific parts).
Another advantage is that it is easier with MongoDB to scale, you can add many servers to a cluster share the data between them.
The pros come with cons.
Drupal as a whole can't be switched to MongoDb, so you will have to support two databases and make sure they work well together.
Many modules will not be able to work with mongodb so you will loose interoperability.
Unless you have a pressing need (like part of your system is not coping with the number of request/or amount of data) I wouldn't switch. And even when you start approaching limits look at throwing hardware at the problem or tuning before switching.
I thought I had answered this before, there is a almost duplicate on SO