MongoDB development practices

Source: Internet
Author: User

One of the representatives who used NoSQL in the project years ago, MongoDB, summed up some experiences on Weibo. I would like to share with you here.
 
Refreshing use of MongoDB in development
 
MongoDB is a # NoSQL # database suitable for PHP development. It supports high concurrency and schema-free (free structure) features, making PHP development more flexible and efficient. Let's try it all!
 
In many cases, it is difficult to recall or locate the free fields recorded in mysql (such as serialized arrays. However, mongodb allows you to easily find the desired array, which is regular (conditional query ). This is easy to understand.
 
In the case of large data volumes, the efficiency of orderby and groupby is very low. From the perspective of current practices, mongodb is very promising and necessary to replace orderby and groupby, because of its flexible data structure model, it can be used as a cache layer for data that can be searched, sorted, and classified, and the efficiency is much higher than that of mysql.
 
Thoughts on MongoDB application scenarios
 
Important data: mysql, General Data: mongodb, temporary data: memcache
 
For relational data tables, mongodb provides a faster view. For PHP programs, mongodb can be used as a persistent array, this persistent array also supports sorting, conditions, and restrictions.
 
Replacing some of the functions of mysql with mongodb is mainly to consider mongodb as a view of mysql. view is the key to integrating table data into business data. For example, to report raw data, you need to calculate the raw data and generate a view to query and report the view. In this sense, mongodb provides a faster and more usable view
 
Notes for using MongoDB in PHP
 
Mongodb and other noSQL technologies are good choices as an intermediate view between memcache and mysql. NoSQL persistence is a very bad thing. Unless an SSD hard disk is available, persistence will cause a great burden on the system under normal hard disk conditions, and the efficiency may even be lower than that of mysql.
 
When you use PHP to operate MongoDB, the sorting field value must be of the forced type. Otherwise there will be problems in sorting. When the type is not forced, it will be in the following format: 1 10 2 3 solution is to add (int) $ sort to force the type when writing.
 
MongoDB encountered the exception of "Caught exception: non-utf8 string:", which is thrown when inserting non-UTF8 encoded text
 
The above are my experiences on using MongoDB on Weibo. What do you think? Welcome to comments!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.