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.
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.
db.honyarara.remove({});
Farewell.
https://docs.mongodb.org/manual/indexes/
(Assumption that data is not entered or deleted again)
db.honyarara.createIndex( { "$**": "text" } )
--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.
If you have more complex queries or tunings, we recommend that you no longer use mongodb.
db.honyarara.getIndexes()
db.tracks.dropIndex (index name)
Recommended Posts