The characteristics and merits of MySQL and MongoDB
Http://www.cnblogs.com/eternal1025/p/5419905.html
First, we analyze the characteristics and merits of MySQL and MongoDB. Here is the part of the PPT I used to do.
Then analyze the application scenario, a. If you need to use MongoDB as back-end db instead of MySQL, where MySQL is parallel to MongoDB, then there are several scenarios in which this may be considered: (1) The part of MongoDB is stored in document form, Can have good code affinity, direct writing in JSON format is convenient. (such as logs, etc.) (2) Consider atomicity from the data models design phase, without the need for assistance such as transactions. Development using language such as Nodejs to develop, it is more convenient for development. (3) The failover mechanism of MongoDB itself does not need to be implemented in such a way as MHA.
This situation is also a lot of, my hands on the game is Nodejs+mongodb, the total user is also tens other, water what is good.
B. Use MongoDB as a redis-like, memcache to cache db, serve MySQL, or back-end log collection analysis. Given that MongoDB is a nosql database, SQL statements and data structures are not as friendly as MySQL, and there will be times when MongoDB is used as a cache db such as Redis memcache, which is used to assist MySQL. or only for log collection analysis.
Question 2: The landlord may not observe carefully. I did the experiment. Examples are as follows: > db.a.save ({"A": 3}); > db.a.save ({"A": 4}); > db.a.find () { "_id" : objectid ("540826eb0e83c3fb7ea07a0f"), "a" : 3 } { "_id" : objectid ("5416869a9fa8a67830dfc9a8"), "a" : 4 } > Db.a.find (). Sort ({a:1}) { "_id" : objectid ("540826eb0e83c3fb7ea07a0f"), "a" : 3 } { "_id" : objectid ("5416869a9fa8a67830dfc9a8"), "a" : 4 } > Db.a.find (). Sort ({a:-11}) { "_id" : objectid ("5416869a9fa8a67830dfc9a8"), "a" : 4 } { "_id" : objectid ("540826eb0e83c3fb7ea07a0f"), "a" : 3 } > Db.system.profile.find ({"ns": "TEST.A"}) { "op" : "Query", "ns" : "TEST.A", " Query " : { " Query " : { }, " by " : { " a " : 1 } }, "NtorEturn " : 0, " Ntoskip " : 0, " nscanned " : 2, " Scanandorder " : true, "Keyupdates" : 0, "Numyield" : 0, "Lockstats" : { "Timelockedmicros" : { "R" : numberlong (156), "W" : numberlong (0 ) }, "Timeacquiringmicros" : { "R" : numberlong (4), "W" : Numberlong (3) } }, "nreturned" : 2, "ResponseLength" : 86, " Millis " : 0, " ts " : isodate (" 2014-09-15t06:26:36.681z "), " client " : " 127.0.0.1 ", " allUsers " : [ ], " user " : " " } { " Op " : " Query ", " ns " : " TEST.A ", " Query " : { " Query " : {  }, "by" : { "a" : -11 } }, "Ntoreturn" : 0, " Ntoskip " : 0, "Nscanned" : 2, "Scanandorder" : true, "Keyupdates" : 0, " Numyield " : 0, " Lockstats " : { " Timelockedmicros " : { " R " : numberlong (, ) "W" : numberlong (0) }, "Timeacquiringmicros" : { "R" : numberlong (4), "W" : numberlong (3) } }, "nreturned"  : 2, "ResponseLength" : 86, "Millis" : 0, "ts" : isodate (" 2014-09-15t06:26:39.125z "), " client " : " 127.0.0.1 ", " AllUsers " : [ ], "User" : " }
The use of sort is not placed in query, but instead has a separate field to store. such as the Scarlet Letter section above.
5.mysql,emysql
Https://github.com/Eonblast/Emysql
1. Step-by-step development (use of the Erlang server for the game account database)