Spring Boot. I need to execute two commands, saveAll and findById, but only for one collection. I want it to be as fast as possible. Do you know of a good library for this?
Why not use spring data mongodb?
I think it is not for performance
But your saying saveAll and findById, do you mean you want to use repository interfaces or just the operation s?
I think the performance is ok with this library. Do you gave a large collection?
I'll add to what Alireza has mentioned already. It's not just that spring-data-mongodb performance is fine. It's that performance differences of DB clients is negligible compared to the DB performance and network calls. If you care about performance that much, then you should first look at the choice of DB, your data model, indexes, and that indexes fit into ram. That is what will give you 99.9999% of performance, not the choice of the client library. Yeah, client library may make a difference under certain circumstances. But that's usually a result of a different kind of requirements, not what you described. Also, if your collection takes 200Gb (holy sh*!!!!, that's huuuuge), then you need to pay attention to your indexes sizes. If your main call is "findById", then check that index for id field fits into ram. If it doesn't, then DB will have to continuously swap pieces of the index while performing a simple "findById" operation. Which kind of defeats the whole purpose of indexes. And obviously will result in a significant performance degradation, especially with the increasing number of parallel "findById" requests. And another recommendation. If you have 200Gb collection, then most likely you're doing something wrong. Make sure that you learn about data modeling patterns and anti-patterns in mongo (google for something like "mongodb patterns" and "mongodb anti-patterns"). Here's a list of my bookmarks: https://www.mongodb.com/docs/manual/data-modeling/ (check all sub-sections there) https://www.mongodb.com/blog/post/building-with-patterns-a-summary https://www.mongodb.com/developer/products/mongodb/schema-design-anti-pattern-summary/ https://www.mongodb.com/docs/manual/applications/data-models/
Hey, thanks. The collection can get up to 200 GB because it keeps info from a week ago. I think it's too much, but it's not up to me. Anyway, I think the action that was slow was saveAll, not findByID.
what's the performance of "save 1"? you may need to know the specific size
The problem was that I was running locally and not on an environment
what's the difference between local and environment? have you thought split data to 2 or more database?
Lock it on my PC environment is on osft and has more resources
Обсуждают сегодня