GithubHelp home page GithubHelp logo

mysql-mongodb-simple-kv-pair-benchmark's Introduction

MySQL vs MongoDB simple k-v pair benchmark

Prepare

Create MySQL table

CREATE TABLE `kv` (
	`k` CHAR(100) NOT NULL COLLATE 'utf8mb4_unicode_ci',
	`v` MEDIUMBLOB NULL DEFAULT NULL,
	PRIMARY KEY (`k`)
)
COLLATE='utf8mb4_unicode_ci'
ENGINE=MyISAM
;

MongoDB collection index is automatically created in mongodb_write.php with the following code.

$collection->createIndex(['k' => 1], ['unique' => true]);

Result

Item Value
MySQL Write 25s / 20000 insert * 100000 bytes
MongoDB Write 24.8s / 20000 insert * 100000 bytes
MySQL Read 5.3s / 20000 select * 100000 bytes
MongoDB Read 14.4s / 20000 find * 100000 bytes
Item Value
MySQL Write 20.6s / 200000 insert * 1000 bytes
MongoDB Write 36.6s / 200000 insert * 1000 bytes
MySQL Read 20.9s / 200000 select * 1000 bytes
MongoDB Read 51.6s / 200000 find * 1000 bytes

So, is RDBMS slow and NoSQL fast? Is there any problem in my test script?

I could also test using InnoDB with auto commit disabled (SET AUTOCOMMIT=0;). It got same time like MyISAM. When auto commit enabled. It costs 30 times time as the former one. 7.2s for 2000 insert * 1000 bytes.

MySQL is really fast if you use bulk insert or SET AUTOCOMMIT=0 before insert. (BEGIN TRANSACTION and COMMIT is same as autocommit=0) You cannot say that MySQL is slow than MongoDB generally. But you can say that under specific circumstances. What's more. You can optimize you MySQL database schema to get similar performance like MongoDB or even better.

mysql-mongodb-simple-kv-pair-benchmark's People

Contributors

ganlvtech avatar

Stargazers

ThevenRex avatar Hieu Nguyen avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.