Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Mongoid

You're reading from   Learning Mongoid If you know MongoDB and Ruby, then Mongoid is a very handy tool to have at your disposal. Quickly learn to build Rails applications with the helpful code samples and instructions in this book.

Arrow left icon
Product type Paperback
Published in Dec 2013
Publisher Packt
ISBN-13 9781782167501
Length 140 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Gautam Rege Gautam Rege
Author Profile Icon Gautam Rege
Gautam Rege
Arrow right icon
View More author details
Toc

Good practices and recommendations


Here are some of the best practices that should be followed while working with MongoDB:

  • Use indexing judiciously. Try to keep multikey indexes such that we do not need to duplicate indexes. Database writes are slowed down with lots of indexes, but reads could be fast. We need to strike the right balance.

  • Use the aggregation framework as often as possible. Remember Mongoid caches results for even better performance.

  • MapReduce is a great tool to get faster aggregated results. However, you cannot use it with multiple collections.

  • Know when to use Text indexes, it's fine for really simple searches but not good if you want complex facet queries. If you require complex facet queries, I recommend looking at ElasticSearch.

  • Use the hash index for basic field searches, but not for multikey searches as we have seen.

  • Keep an eye out for slow queries.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image