[英]Spring WebFlux. There are two ways to get data from database (direct and flux-operators)? What difference?
I use Spring Data and WebFlux. 我使用Spring Data和WebFlux。 I have two ways to get data from the database.
我有两种方法从数据库中获取数据。
First way: I can get data using a request like - 第一种方式:我可以使用类似的请求获取数据 -
Flux(?) findAllByName(String name)
Second way: I can use operators since I use WebFlux 第二种方式:因为我使用WebFlux,所以我可以使用运算符
findAll().filter(x -> x.name.equals(name))
What is the difference? 有什么区别?
Which one is better? 哪一个更好?
For Flux(?) findAllByName(String name)
filtering happens inside the database that returns only records with a matching name. 对于
Flux(?) findAllByName(String name)
过滤在数据库内部发生,该数据库仅返回具有匹配名称的记录。
For findAll().filter(x -> x.name.equals(name))
you get all the records from the database (table, document collection, ...) and filter them inside your application. 对于
findAll().filter(x -> x.name.equals(name))
您将获取数据库中的所有记录(表,文档集合,...)并在应用程序中过滤它们。
If your database stores gigabytes of data, moving it all around the network is not a viable strategy. 如果您的数据库存储了数十亿字节的数据,那么在网络中移动它并不是一种可行的策略。 Therefore the first variant is preferred.
因此,第一种变体是优选的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.