Which is better between MySQL and MongoDB

Which is better between MySQL and MongoDB

Summary:This article describes Anders After Karlsson found that MySQL was at a disadvantage in comparison with MongoDB, he tried his best to improve MySQL. Various storage engines, various memory management engines and embedded ideas, MySQL finally won after various attempts. But can this kind of victory really be called a victory? Or is this kind of victory really what everyone wants? Preliminary key-value comparison, MongoDB wins Faster and faster, this has always been our goal for the database system MySQL Does it really make sense that Dragster cites disk speed as its biggest obstacle? Let’s just take it as an obstacle, what about the solution? ! If an obstacle restricts your Dragster, you can choose to go around it faster or improve your computer. for example: Avoid using disks, replace them with memory as much as possible Use a faster disk (such as SSD) Actually the above pair of analogies is not good, because the limitation from the disk is so large, and surprisingly never improved. You might say, don’t we have SSD? Yes, this does boost the hard drive, but don’t forget: the CPU and RAM can be boosted faster than the hard drive! But let’s assume that our…

Comparison of query performance test between MongoDB and MySQL

Recently, I want to use Mongodb to do some storage layer things. At present, it is mainly used in id query or ids query (such as mysql‘s in Inquire). Whether the new solution can be launched depends on performance. Now compare mongodb with mysql. Environment: the same machine, equipped with mongodb 1.4, mysql; memory 4g; both databases only have unique search of id; data volume 120w About 5w queries. Do an id or ids query on them. the mongodb mysql total time avg time/per query total time avg time/per query 1 id/per query 11954ms, 00:11,954 0ms, 00,0 78613ms, 00:1:18,613 1ms, 00,1 10 id/per query 35885ms, 00:35,885 0ms, 00,0 107274ms, 00:1:47,274 2ms, 00,2 20 id/per query 63714ms, 00:1:3,714 1ms, 00,1 186398ms, 00:3:6,398 3ms, 00,3 5 threads, 20 id/per query – 5ms, 00,5 – 11ms, 00,11 10 thread, 20 id/per query – 10ms, 00, 10 – 22ms, 00, 22 the From the table above: For each query of an id, mongodb is 7 times faster than mysql under basically the same conditions. For queries with multiple ids (10/20) per query, mongodb is 2 times faster than mysql. Check multiple ids under multi-threading, mongodb is 1 times faster than mysql. From the above…

The difference between MySQL and MongoDB database design

MySQL is the star among relational databases, and MongoDB is the leader among document databases. Let’s compare the two through a design example: Suppose we are maintaining a mobile phone product library, which contains not only basic information such as the name and brand of the mobile phone, but also parameter information such as standby time and appearance design. How should we access the data? If you use MySQL, the basic information of the mobile phone is a separate table. In addition, because the parameter information of different mobile phones is very different, a parameter table is needed to save it separately. CREATE TABLE IF NOT EXISTS `mobiles` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` VARCHAR(100) NOT NULL, `brand` VARCHAR(100) NOT NULL, PRIMARY KEY (`id`) ); CREATE TABLE IF NOT EXISTS `mobile_params` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `mobile_id` int(10) unsigned NOT NULL, `name` varchar(100) NOT NULL, `value` varchar(100) NOT NULL, PRIMARY KEY (`id`) ); INSERT INTO `mobiles` (`id`, `name`, `brand`) VALUES (1, ‘ME525’, ‘Motorola’), (2, ‘E7’ , ‘ Nokia’); INSERT INTO `mobile_params` (`id`, `mobile_id`, `name`, `value`) VALUES (1, 1, ‘Standby time’, ‘200’), (2, 1, ‘Appearance design ‘, ‘straight’), (3, 2, ‘standby time’, ‘500’), (4, 2, ‘appearance design’,…

Concurrency performance test comparison between MySQL and MongoDB

Concurrency performance test comparison between MySQL and MongoDB

As I said in the previous article, I am going to do a concurrency comparison test between MongoDB and Mysql. After nearly a week of testing, it has been completed. The results are as follows: Concurrency comparison test curve between MongoDB and Mysql: Let’s roughly summarize: From the data and charts, we can see that under the concurrency test, the advantage of MongoDB over Mysql is not as great as that of a single user (refer to the previous test article in this space). The insert and update performance of MongoDB is about 2~3 times that of Mysql, and MongoDB is equivalent to Mysql in terms of select. Test environment: CPU: Intel(R) Core(TM)2 Duo CPU E7500 @ 2.93GHz Memory: 4G Hard disk: ordinary SATA hard disk 500G OS: Centos Linux 5.4 X64 Mysql version: 5.0.77, MongoDB is 1.40 compiled by itself. The above results are tested by the Java program (http://farmerluo.googlecode.com/files/mongotest-0.4.rar) written before, because there is only one test machine, and the test program is the same as mysql and MongoDB running the tests on the same machine.

Performance test comparison between MongoDB and MySQL

Today, through an experiment, we compared the performance of MongoDB and MySQL. Note that this comparison only reflects the situation in our application scenario, and does not represent the general situation. We want to store some historical video traffic, which needs to be stored for one year, and the daily active videos are on the order of millions, and the traffic can be represented by an integer. In our application, write performance is a priority factor, so the first step of the experiment mainly compares the write performance. Since the stored data is exclusively shared by a single application (process), sqlite also meets our application scenarios. So we also tested the write performance of sqlite. Experimental environment: Single server RHEL 5.5 64bit, dual-core Intel(R) Xeon(R) CPU 5130 @ 2.00GHz CPU, 8G memory, local disk. Test program (python): MySQL: MySQLdb Sqlite: pysqlite2 MongoDB: pymongo DB Schema: 1. MySQL (InnoDB) & Sqlite: CREATE TABLE `inventory` ( `date` DATE NOT NULL, `id` INT(11) NOT NULL, `views` INT(11) NOT NULL, PRIMARY KEY (`date`, `id`)); 2. MongoDB index inventory.create_index([(‘date’,ASCENDING), (‘id’,ASCENDING)], unique=True, dropDups=True) Test method: In our application scenario, today’s traffic on any item will be randomly inserted or updated. Therefore, we test insert and update…

Efficiency comparison between MongoDB and MySQL two databases

1. The first is the memory mapping mechanism. The data is not persisted to the storage device, but is temporarily stored in the memory, which improves the efficiency of IO and the performance loss between the operating system and the storage medium. (After all, memory reading is the fastest) Second, NoSQL does not use sql, just does not use relations. There is no relationship, which means that each data is like having a separate storage space, and then pointed to by a clustered index. Search performance will definitely improve. Third, language. Operations using Javascript syntax are more efficient and straightforward. These are the reasons why MongoDB is more efficient for relational databases. But you can’t just focus on efficiency, there are also some disadvantages brought about by the design of this database. For example, the maintenance of data relationships will bring a lot of redundant data, the client code needs a lot of IO operations on the database, data mining is difficult to implement, and so on. Therefore, it is a priority to select an appropriate data storage medium for the application system.

How to synchronize MySQL database to MongoDB database

How to synchronize MySQL database to MongoDB database

NoSQL is very popular, but to use it in a real environment, many people may still have a lot of concerns. A common practice is to write double data, first observe the situation and then decide whether to migrate. The following tool may be a boon for those students who want to migrate from MySQL to MongoDB. This is not a simple data import tool, but a real-time synchronization of data in MySQL to MongoDB. It is equivalent to MongoDB as a MySQL from library. This tool is based on an open source project called tungsten-replicator, and the tools are all open source. You can directly checkout the code to install and use it now. Schematic: The effect after installation: Execute the following SQL for creating tables and inserting data in MySQL: mysql> create table foo(id int primary key, msg varchar(35)); Query OK, 0 rows affected (0.05 sec) mysql> insert into foo values(1, ‘hello from MySQL!’); Query OK, 1 row affected (0.00 sec) The corresponding data can then be found in MongoDB: > show collections foo system.indexes > db.foo.find(); { “_id” : ObjectId(“4dc55e45ad90a25b9b57909d”), “1” : “1”, “2” : “hello from MySQL!” }

mongodb-web

Detailed step-by-step graphic instructions for installing MongoDB database in Ubuntu system

MongoDB deployment experiment series articles, MongoDB, as a NoSQL database, has continued to heat up in recent years, and more and more companies have begun to try to use MongoDB instead of the original Database to do some things. MongoDB also performs quite well in clustering, sharding, and replication. I will introduce by doing various MongoDB deployment experiments. Preface As a document-based NoSQL database, MongoDB is very flexible to use and avoids the complex database design of relational databases in the early stage. MongoDB storage is based on the JSON format, and Javascript is used as the database operation language, which gives users unlimited imagination. They can solve very complex conditional query problems in the MongoDB server through programming. Directory MongoDB installation in Windows MongoDB installation in Linux Ubuntu Access MongoDB through the command line client 1 MongoDB is installed in Windows It is very simple to install the MongoDB database on the Windows system. Download the executable installation file (exe) and double-click to install it. Download link: http://www.mongodb.org/downloads MongoDB server running command: MongoDB installation directory/bin/mongod.exe MongoDB client run command: MongoDB installation directory/bin/mongo.exe 2 MongoDB is installed in Linux Ubuntu The Linux used in this article is Ubuntu 12.04.2 LTS…

MongoDB and Java Development

Environment configuration If you want to use MongoDB in a Java program, you need to ensure that the Java environment and the MongoDB JDBC driver have been installed. You can refer to the Java tutorial on this site to install the Java program. Now let’s check if you have the MongoDB JDBC driver installed. First you have to download mongo jar package, download address: https://github.com/mongodb/mongo-java-driver/downloads, Make sure to download the latest version. You need to include mongo.jar in your classpath. . Connect to database To connect to the database, you need to specify the database name. If the specified database does not exist, mongo will automatically create the database. Java to connect to the database import com.mongodb.MongoClient; import com.mongodb.MongoException; import com.mongodb.WriteConcern; import com.mongodb.DB; import com.mongodb.DBCollection; import com.mongodb.BasicDBObject; import com.mongodb.DBObject; import com.mongodb.DBCursor; import com.mongodb.ServerAddress; import java.util.Arrays; public class MongoDBJDBC{ public static void main( String args[] ){ try{ // Connect to mongodb service MongoClient mongoClient = new MongoClient( “localhost”, 27017 ); // Connect to database DB db = mongoClient.getDB( “test” ); System.out.println(“Connect to database successfully”); boolean auth = db.authenticate(myUserName, myPassword); System.out.println(“Authentication: “+auth); }catch(Exception e){ System.err.println( e.getClass().getName() + “: ” + e.getMessage() ); } } } Now, let’s compile and run the program…

Java and MongoDB database programming

I used mongodb experimentally this week. The application scenario is very simple, so I don’t know much about mongodb now. This article mainly introduces the java client programming of mongodb. The content in this aspect is also very simple. Here is just a summary. It has to be said that a storage between kv and sql like mongodb is very suitable for many Internet applications. There are many application cases of mongodb now, and the community is very active (many people in China have done in-depth research on it. If I have time and energy, maybe I will also invest in some research on mongodb), which is worth looking forward to. . Closer to home, the following summarizes some of the development of mongodb applications using Java. The most straightforward option for interacting with mongodb in Java is to use MongoDB Java Driver, its download address is: http://github.com/mongodb/mongo-java-driver/downloads. In general, the API for operating mongodb in Java is still very simple, and some common uses of it are introduced below. 1. Connect to the database Example of establishing a connection with mongodb Mongo m = new Mongo(“localhost”,27017); DB db = m.getDB(“db_test”); Although the object db representing the db_test database connection…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索