Query response taking longer using REST call

I am trying to run a n1ql query using the REST call. The program takes an id from the user and runs the query on the backend and returns the flux object to the user. When i run the same query on CB it takes around 13 seconds to return 26000 documents. But using the Java SDK and REST call it takes a really long time.
Below is the example of how I query the data in the repository class and then eventually returning data to the service and controller class.
The Repository class:

public interface ReactiveUserRepository extends ReactiveSortingRepository<User, Long> {
@Query(“SELECT META().id as __id, META().cas as __cas, user_id, firstname, lastname, city, phonenumber, email, postalcode FROM userData where user_id= $1”)
Flux findByUserId(String user_id);

Thanks for the help!