Skip to content

Instantly share code, notes, and snippets.

View MuhammadJamaluddin's full-sized avatar
🎯
Into the wild

Muhammad Jamaluddin MuhammadJamaluddin

🎯
Into the wild
View GitHub Profile
> db.books.find({"_id": 1000}).explain("executionStats");
{
"queryPlanner" : {
"plannerVersion" : 1,
"namespace" : "books.books",
"indexFilterSet" : false,
"parsedQuery" : {
"_id" : {
"$eq" : 1000
}
Insert operations:
id --> performance
10,000,000 --> Query OK, 1 row affected (0.35 sec)
10,000,001 --> Query OK, 1 row affected (0.10 sec)
10,000,002 --> Query OK, 1 row affected (0.05 sec)
10,000,003 --> Query OK, 1 row affected (0.06 sec)
mysql> UPDATE books
-> SET author='Jamal'
-> WHERE id=10000;
> db.books.explain("executionStats").remove({"id": 10000000});
{
"queryPlanner" : {
"plannerVersion" : 1,
"namespace" : "books.books",
"indexFilterSet" : false,
"parsedQuery" : {
"id" : {
"$eq" : 10000000
}
mysql> select * from books where id = 5000000 \G;
*************************** 1. row ***************************
id: 5000000
title: end-to-end emulation XML
author: Hilton Reilly
description: Perspiciatis occaecati et optio quis dolore ea. Laboriosam culpa numquam quo porro qui dicta ratione. Similique atque rem. Exercitationem quis itaque dolores perspiciatis corrupti modi odit impedit. Cupiditate consequatur dolorem optio et dolorum. Cumque facilis itaque quam libero esse cum cupiditate atque quaerat.
image: http://lorempixel.com/480/640/abstract/
rating_five: 62913
rating_four: 8703
rating_three: 55886
@MuhammadJamaluddin
MuhammadJamaluddin / MongoDB.json
Last active June 6, 2019 00:55
The queries are slow (in the range of 50:100 ms) & a lot of times it would even exceed the 100 ms bar although I'm using an index.
> db.books.find({"id": 7945640}).explain("executionStats");
{
"queryPlanner" : {
"plannerVersion" : 1,
"namespace" : "books.books",
"indexFilterSet" : false,
"parsedQuery" : {
"id" : {
"$eq" : 7945640
}
@MuhammadJamaluddin
MuhammadJamaluddin / MongoDBSeeding.js
Created June 6, 2019 00:36
some queries results
const fake = require('faker');
const now = require('performance-now');
const fs = require('fs');
const { Book } = require('./index');
let fakeData;
const CreateFakeDocument = function CreateFakeDocument(i) {
const book = {};

/reviews

  • description: retrieve all the reviews from the database.
  • API response: A JSON-encoded array of objects where each object represent a review. A review object example looks like this:
{
  "_id": "5c99be23d83f3c5994dd1e38",
  "image_url": "http://lorempixel.com/640/480/people",
  "reviewer_name": "Rey Cummerata",
  "star_rate": 5,