With the cumulative update of the database, is there any good plan not to soar to high memory?

as the title, my question is, for example, there is a table with five pieces of data in it, respectively

/* 1 */
{
    "_id" : ObjectId("5b50807f334ca1071be530aa"),
    "a" : ,
    "a" : 2
}

/* 2 */
{
    "_id" : ObjectId("5b508089334ca1071be530ac"),
    "a" : ,
    "b" : 3
}
/* 3 */
{
    "_id" : ObjectId("5b508092334ca1071be530ae"),
    "a" : ,
    "b" : 5
}

/* 4 */
{
    "_id" : ObjectId("5b508092334ca1071be530ae"),
    "a" : ,
    "b" : 4
}

first of all, my purpose is to sort. Let"s take our usual query condition of certain data to be higher than the others. Take the third item, Zhang San, for example. (suppose the query is found according to the b field and then sort the output.) now his b field is 5. I want to mention it to 1, OK, update it right away, and then Zhang San goes up, and then I have to accumulate and sort other data at once, so, Here comes the problem

I have to find all the other data except Zhang San"s data from the b field first, and then sort them (this is not the point). When the key points come, I have to update them in turn. All I can have is for, and then accumulate. In such a scheme, we have to deal with less data. If there are tens of thousands of items, isn"t it a pill? Memory skyrocketing, direct GG. Moreover, the nodejs,v8 memory is already tight. To do so is to commit suicide by poisoning yourself. If you have any plans, please give us some advice

.
Mar.28,2021

the effect you want is to change the sort order of a piece of data, which does not mean that you need to modify all the sort codes.

for example: the existing sort is a 1, b 2, c 3, if you want to change the order of c to the first place, then the corresponding number of c can be changed to 0, and there is no need to change other data.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea9ea3-1f90.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea9ea3-1f90.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?