4

I'm trying out the new ReactiveQuerydslPredicateExecutor in my project but i can't find a method for findAll(Predicate, Pageable) like i had in QueryDslPredicateExecutor

Is this intentional? Does it mean for reactive it's not recommended to use Pagination ?

user1955934
  • 3,185
  • 5
  • 42
  • 68

1 Answers1

0

in a reactive world, there is no use of something pageable because by default entities will be emitted as soon as they are available.

Think of it as a stream of data that just flows as soon as new data is available. If you wish to control the flow of data there are a number of methods that will tweek the flow. These are things like prefetch that will get n number before emitting them.

Or limitRate(N) splits the downstream requests so that they are propagated upstream in smaller batches.

you can read more about how to control the flow of data here: Operators changing the demand from downstream

Toerktumlare
  • 12,548
  • 3
  • 35
  • 54
  • what about query performance? im thinking what if query rsults are milllions and i need the nth page of that results? – user1955934 Jul 02 '19 at 12:00
  • If the query is slow, the response will be slow. If you do a request/response that takes 1 sec to fetch from the database, it will always take 1 sec. The difference is that in a non reactive application the assigned thread eould block until the database responds, while in a reactive world the thread would start handling new incoming requests instead of waiting, and any avaliable thread would finish the request when the call to the db has finished. – Toerktumlare Jul 02 '19 at 12:20
  • another thing is that if you ask for say all million records, if using a non blocking driver with say monogodb, it will send the records as they become fetched in a stream like fashion. So it wouldnt fetch one million records and then start sending them to the client, it will fetch batches and then push these out as quick as possible. – Toerktumlare Jul 02 '19 at 12:25
  • i meant using the reactivequerydsl, which i cannot provide pageable, i need to fetch the whole results up to the page i request. Wouldn't this be slower? non reactive querydsl i can provide pageable so that query to database can jump to the specific page i want. – user1955934 Jul 03 '19 at 00:28
  • Also, it is common to show : "Showing 50 out of 10203 results". How do I get this totalElements efficiently? – user1955934 Oct 03 '19 at 08:13
  • This seems to be intentional https://jira.spring.io/browse/DATAMONGO-2031 (answer not limited to mongo) – stilgar Apr 08 '20 at 11:35