Performance benchmark comparisons between two of the most used RDBMS and NoSQL DBMS
- "npm init - y" followed by "npm i postgres express"
- Get latest postgres docker image: "docker pull postgres"
- Run the following command to run the postgres container: " docker run --name postgres-container -e POSTGRES_PASSWORD=mysecret -d -p 5432:5432 postgres "
- List down the containers (docker ps) and pick up your container, and its ip address as host
- interactive view to postgres container: docker exec -it postgres-container bash
- connect postgres: psql -h localhost -U postgres
- \l : to see all databases
- CREATE DATABASE performance
- \c or \connect performance : to connect with "performance" db
- CREATE TABLE test_one ( id SERIAL PRIMARY KEY, sequence INTEGER, constext TEXT );
- INSERT INTO test_one (sequence, constext) SELECT generate_series(1000,2000), 'input random string to check the performance';
- \dt
- curl -s -o /dev/null -w "Response time : %{time_total} seconds\n" GET http://localhost:8240/data Response times: Command: "curl -s -o /dev/null -w "Response time : %{time_total} seconds\n" GET http://localhost:8240/data" (a) All of 1000 rows : 0.018906 seconds = 18.906 ms (b) Self Join on 1000 rows : 0.811307 seconds = 811.307 ms (c) Self Conditional Join: 0.011466 seconds = 11.466 ms
- "npm init - y" followed by "npm i mongoose express"
- Get latest mongo docker image: "docker pull mongo"
- Run the following command to run the postgres container: " docker run -d --name mongodb-instance -p 27017:27017 mongo "
- docker exec -it mongodb-instance bash
-
docker exec -it mongodb-instance bash
-
mongosh
-
use performance
-
for (let i = 0; i<1000; i++) { ... db.Test.insertOne({ sequence: i, constext: "random string" + i }); ... }
-
db.Test.find().count();
-
Response times: Command: "curl -s -o /dev/null -w "Response time : %{time_total} seconds\n" GET http://localhost:8280/test" (a) All of 1000 rows : 0.021102 seconds = 21.102 ms (b) Self Join : NA
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 39 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Vendor ID: GenuineIntel
Model name: Intel(R) Core(TM) i5-6500T CPU @ 2.50GHz
CPU family: 6
Model: 94
Thread(s) per core: 1
Core(s) per socket: 4
Socket(s): 1
Stepping: 3
CPU max MHz: 3100.0000
CPU min MHz: 800.0000
BogoMIPS: 4999.90
Virtualization features:
Virtualization: VT-x
Caches (sum of all):
L1d: 128 KiB (4 instances)
L1i: 128 KiB (4 instances)
L2: 1 MiB (4 instances)
L3: 6 MiB (1 instance)