Has anyone ever used leveldb? I used it in nodejs environmenthttps://www.npmjs.com/package …
After searching the information on the internet, I still feel very little. Not to mention the users.
However, it doesn’t matter. Even if it hasn’t been used, I can still look at the following questions.
The problem I am facing now is. The test data is about one million. If you look up by key alone, it is very fast.
But now I need to do something like this
where name='a' order by dateline desc limit 100,50
In any case, you must read all the records from the database, then sort them, and then intercept the corresponding data segments.
However, it took 4 minutes to read all the records, 1 million pieces of data, and this speed obviously cannot be used in actual production.
I don’t understand mysql, which has 1 million pieces of data, so it should take less than 1 second to implement the above sql. How did they do it?
Do you have any ideas?
I think the subject has misunderstood the way the database works. Databases often use abalanced treeInstead of simply storing an array and sorting the array when it is used, the data structure of the
descThe order of 100 to 150 (I may have misunderstood this limit) is not to read all the data, but to find the subtree with the size of 150 at the bottom left from the balanced tree, and then find it from the right subtree of this subtree.
name = 'a', and then take out the data of that node. This is a simple principle of the database. In fact, the database will put some data in an external storage device and then create this external storage area in memory.
AIndex. If the index is found during the search, the data on the external storage device will be read into the memory to build onebalanced tree, look up in this balance tree. This is a realization of organizing data in a database.
The execution time of this query statement in mysql is very short, but if it is to obtain all the data, it will also take a long time.
In the end, I still don’t understand the functions implemented by the subject. What I don’t understand is: 1. Is the data read from the database or just stored in the file? 2. If it is necessary to traverse all the data, for example, all the data must be displayed or all the data must be stored in some other file, then the bottleneck that actually limits the speed is the programming language, operating system, etc.