Who knows the replacement for MongoDB?

In mongoDB two-tier model organization of data: collection of JSON documents.
This is OK for small resources, for example, for a blog where there are only posts.
But if each user has their posts? All the posts shoved into one collection or one array? If you want to implement something more or less normal, it is necessary to write a crutch on a crutch.
Need at least a three-tier model.

To insert a document in a collection can only be in the end.
For example, insert the post into the collection, and I need to get posts by date.
You can certainly search to do it all, or to write a crutch with skip, limit.

If you need to insert at the beginning of the collection, it would be much easier.

MySQL? Potgresql? REDIS? Any other?
Prompt, please, who knows a better alternative.
July 9th 19 at 11:14
6 answers
July 9th 19 at 11:16
In mongoDB two-tier model organization of data: collection of JSON documents.
This is OK for small resources, for example, for a blog where there are only posts.
But if each user has their posts? All the posts shoved into one collection or one array? If you want to implement something more or less normal, it is necessary to write a crutch on a crutch.
Need at least a three-tier model.

Take any relational such as mysql or mariadb.
Which one is better in your opinion? - Oscar.Grimes52 commented on July 9th 19 at 11:19
: for a blog without a difference - xavier.Breitenberg21 commented on July 9th 19 at 11:22
: made of mariadb based on mysql and greatly improves it.. the Problem is that probably nobody uses it massively (when searched for, not found). Everywhere php+mysql was. - abigail36 commented on July 9th 19 at 11:25
July 9th 19 at 11:18
What's the problem? You something to do, and the problem is not Mongo, but as they say in the gasket between the chair and the monitor.

collection nick -> id, email, password
collection post -> id, user_id, post_content

var user = users.find(1);
var posts_by_user = posts.find({ user_id: user._id });
A collection of posts user -> username, id -> 1000 posts in a single array? - Oscar.Grimes52 commented on July 9th 19 at 11:21
: what's the problem with the number of posts? skip/limit to help. Why the standard pagination, which is in any database is a crutch? - xavier.Breitenberg21 commented on July 9th 19 at 11:24
With this approach, you need relational, and then you decide a microscope to hammer nails. - abigail36 commented on July 9th 19 at 11:27
: skip limit, it is for documents in the collection. I that for each user collection to create? It is understandable that it is not designed for this - Oscar.Grimes52 commented on July 9th 19 at 11:30
: there you have one collection with posts from all users, only each post in the collection has a user_Id who owns the post. Make a selection by user_id and limits. The output pagination on posts per user. You don't understand something apparently. - bailee_Stant commented on July 9th 19 at 11:33
: And it is normal that all the posts in one collection? If 100k posts? - abigail36 commented on July 9th 19 at 11:36
and if 200k?) Did you use mysql or another relational database? There are generally millions. In many, too, can millions store, but that's another story. - Oscar.Grimes52 commented on July 9th 19 at 11:39
"Okay." Probably Mongo will remain - bailee_Stant commented on July 9th 19 at 11:42
: Thank you - Oscar.Grimes52 commented on July 9th 19 at 11:45
July 9th 19 at 11:20
Well, I can advise, as an alternative, Elasticsearch. But I'm afraid it is you still do not like, although in my opinion very even. In my opinion, you just do something with the data, and what problems to choose the last 10 date? It's an ordinary search index, everything has to move very quickly.

PS.
: And Yes, as an alternative to sorting, I propose to use REDIS. When you add a post in Mongu, add the id of the post more, and in a REDIS list.
rpush user_posts:id1234 321
From radishes to get a single request IDs of the last n-records
lrange user_posts:id1234 10 -1
Why can't things be easier? It is possible for timestamp only search to do the same - Oscar.Grimes52 commented on July 9th 19 at 11:23
is it difficult?!
db.foo.find().sort({_id:1}).limit(50); - xavier.Breitenberg21 commented on July 9th 19 at 11:26
: I understand that you are confused sort? Well, you are not working with relationname databases!!! There is data actually not always a database gives consistently! Especially if it is in the cluster, especially if before these to make the removal of the pile of records!
As an example, puts a hundred thousand entries are deleted from them 50 thousand, write again. Many records fall on the vacant empty space. And so repeat 10-15 times. Make the sample without sorting and wonder :-) - abigail36 commented on July 9th 19 at 11:29
: And Yes, as an alternative to sorting, I propose to use REDIS. When you add a post in Mongu, add the id of the post more, and in a REDIS list.
rpush user_posts:id1234 321
From radishes to get a single request IDs of the last n-records
lrange user_posts:id1234 10 -1 - Oscar.Grimes52 commented on July 9th 19 at 11:32
July 9th 19 at 11:22
But if each user has their posts? All the posts shoved into one collection or one array?

Why? The posts in one collection - it is quite OK. find topics find topics in other collections is also approx.

If you want to implement something more or less normal, it is necessary to write a crutch on a crutch.

Do not write a crutch on a crutch, first, design the database to avoid this.

To insert a document in a collection can only be in the end.

What's the problem (I have a secret: it happens almost every DBMS)? What do you care where it is inserted? Do sample sorting.

For example, insert the post into the collection, and I need to get posts by date.

RTFM

write a crutch with skip, limit.

What a bad man you a game said? If you have records 10кк, you just RAM is not enough to make such selections, without skip/limit.

If you need to insert at the beginning of the collection, it would be much easier.

Are you trying to tear out tonsils through the anus, and the other person.

Prompt, please, who knows a better alternative.

Once again, you invented a problem and are trying heroically to solve, but the problem is that you are not properly using the tools we offer mongo, other database you no it does not help
The other DB just to help, the man tries to haul in Mongo principles and architecture acceptable for relational, Mongo doesn't work. Lots of tables, lots of ties - Mongo is a long time to chew, especially when 10кк of records on each table, and relazione a fraction of a second will work. - Oscar.Grimes52 commented on July 9th 19 at 11:25

Ties will be less than relazione, as in the document, you can put "embedded" data that relate specifically to it (without fanaticism of course). In the case of relazioni will need more tables and more joynow.

I'm not arguing for his case probably relazione better, but the problem that he put forward are resolved is fundamentally different.
In the same MySQL that will insert in the beginning of the table? May limit/offset to use do not have to? - xavier.Breitenberg21 commented on July 9th 19 at 11:28
July 9th 19 at 11:24
What's wrong with MongoDB?
We once did a service on loopback realtime nodejs + mongoDB
A lot of users, millions of records, more than 6000 requests per second. And all flies
And systemic characteristics of what? - Oscar.Grimes52 commented on July 9th 19 at 11:27
: We are on Amazon, like operatives on a 2 gig took increasing to 6 at the peak - xavier.Breitenberg21 commented on July 9th 19 at 11:30
Depends on the implementation how to write and fly. Noda is unforgiving, unlike php. - abigail36 commented on July 9th 19 at 11:33
July 9th 19 at 11:26
Potgresql

Find more questions by tags DatabasesMySQLMongoDBPostgreSQLRedis