[PYTHON] Mongodb Shortest Introduction (3) I tried to speed up even millions

Mongodb Shortest Introduction (1) Install & start on EC2 & suddenly put tens of thousands of items continued The shortest introduction to Mongodb (2) I searched for tens of thousands of cases.

Now that we have an API, let's try a lot more. As expected, t2.micro is impossible, so go to m3.medium. It became a tricycle → a bicycle.

After all it is slow if you put a lot, so I will put an index.

So far, it's the minimum as a casual DB. Searching for files is indexing.

once again. Useful at the development stage.

When refilling everything.

sudo service mongod stop

Did you stop? It looks like Mysql's innoDB, but it seems that journaling files are getting bigger and bigger. Even if you erase the data, something seems to grow under / var / lib / mongo. It's pretty big data, so it's good to have a clean state every time you develop. I'll try again with ** Crispy, Tturn! **. (Yoiko must not imitate)

sudo rm -rf /var/lib/mongo/*

Delete the files under / var / lib / mongo /. Keep the directory.

Start up

sudo service mongod start

The empty / var / lib / mongo / has been initialized.

Erase by collection (Click here for Yoiko)

db.honyarara.remove({});

Farewell.

The main subject. mongotan has an index.

https://docs.mongodb.org/manual/indexes/

(Assumption that data is not entered or deleted again)

I'll fit it all. When there is nothing to look for.

db.honyarara.createIndex( { "$**": "text" } )

When the text type and numbers are separated.

--Ordinary index

db.honyarara.createIndex ({"column name": 1}) value is 1 ascending order-1 descending order

--Text type (when it is a language)

db.honyarara.createIndex ({"column name": "text", "column name 2": "text", ....})

It can be all, or it can be specified

Click here for the text index ↓ https://docs.mongodb.org/manual/core/index-text/#create-text-index

Now, in most cases it should be faster. It takes time, but it's better to be quick.

When it's still late

If you have more complex queries or tunings, we recommend that you no longer use mongodb.

After all when quitting.

  1. Start over with the above procedure
  2. Delete only the index (Click here for Yoiko)

Check current index and name

db.honyarara.getIndexes()

After checking the "name" field, specify and delete

db.tracks.dropIndex (index name)

Recommended Posts

Mongodb Shortest Introduction (3) I tried to speed up even millions
I tried to speed up video creation by parallel processing
[Introduction to PID] I tried to control and play ♬
Mongodb Shortest Introduction (2) I searched for tens of thousands
[Introduction to Pytorch] I tried categorizing Cifar10 with VGG16 ♬
[Introduction to AWS] I tried playing with voice-text conversion ♪
What I did to speed up the string search task
I tried to learn PredNet
[I tried using Pythonista 3] Introduction
I tried to organize SVM.
[Introduction to simulation] I tried playing by simulating corona infection ♬
I tried to implement PCANet
Introduction to Nonlinear Optimization (I)
Ubuntu blew up when I tried to change my username
[Introduction to Pandas] I tried to increase exchange data by data interpolation ♬
[Introduction to infectious disease model] I tried fitting and playing ♬
I tried to reintroduce Linux
I tried to introduce Pylint
I tried to summarize SparseMatrix
I tried to touch jupyter
I tried to implement StarGAN (1)
I tried to implement Deep VQE
I tried to create Quip API
Numba to speed up as Python
I tried to implement adversarial validation
I tried to explain Pytorch dataset
I tried Watson Speech to Text
I tried to touch Tesla's API
Project Euler 4 Attempt to speed up
I tried to implement hierarchical clustering
How to speed up Python calculations
I tried to organize about MCMC.
I tried to implement Realness GAN
[DRF] Snippet to speed up PrimaryKeyRelatedField
I tried to move the ball
I tried to estimate the interval.
I tried to summarize the general flow up to service creation by self-education.
I tried to summarize Cpaw Level1 & Level2 Write Up in an easy-to-understand manner
I tried to summarize Cpaw Level 3 Write Up in an easy-to-understand manner
I tried fMRI data analysis with python (Introduction to brain information decoding)
I tried to create a linebot (implementation)
I tried to summarize Python exception handling
I tried to implement PLSA in Python
I tried using Azure Speech to Text.
I tried to implement Autoencoder with TensorFlow
I tried to summarize the umask command
I tried to implement permutation in Python
I tried to create a linebot (preparation)
I tried to visualize AutoEncoder with TensorFlow
I tried to recognize the wake word
I tried to get started with Hy
I tried to implement PLSA in Python 2
Python3 standard input I tried to summarize
I tried to classify text using TensorFlow
I tried to summarize the graphical modeling.
I tried to implement ADALINE in Python
I tried to let optuna solve Sudoku
[Introduction to Pytorch] I played with sinGAN ♬
I tried to touch the COTOHA API
I tried to implement PPO in Python
I tried to implement CVAE with PyTorch