简体   繁体   English

Spring WebFlux。 从数据库(直接和通量运算符)获取数据有两种方法吗? 有什么区别?

[英]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.

相关问题 如何在 Spring Data / Webflux 中使用可选属性 - How to use optional attributes in Spring Data / Webflux 使用Spring Data和Reactive MongoDB推动流量 - Push a Flux using Spring Data with Reactive MongoDB 在Spring Data JPA中使用Join JPA的方式有什么不同 - What is different of ways when using join jpa in spring data jpa 用于两个数据库连接的通用 spring 数据存储库 - Generic spring data repositories for two database connections Spring-data-elasticsearch:无法从 Flux 转换<searchhit<sugestao> > 助焊剂<sugestao>更新到 7.6.2 后。 如何处理SearchHit? </sugestao></searchhit<sugestao> - Spring-data-elasticsearch: cannot convert from Flux<SearchHit<Sugestao>> to Flux<Sugestao> after updated to 7.6.2. How deal with SearchHit? Spring Data @NamedQuery和@NamedNativeQuery有什么区别? - Spring Data what is the difference between @NamedQuery and @NamedNativeQuery? Spring数据JPA中CrudRepository和JpaRepository接口有什么区别? - What is difference between CrudRepository and JpaRepository interfaces in Spring Data JPA? 使用 spring webflux-reactor 嵌套数据访问调用 - Nested data access calls with spring webflux-reactor "查询方法 find...By、read...By、query...By 和 get...By 在 spring 数据中有什么区别?" - What is the difference between query-methods find…By, read…By, query…By, and get…By in spring data? Spring Entity Manager 和 Spring Data Repository 之间有什么区别? - What is the difference between an Spring Entity Manager and Spring Data Repository?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM