You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2024/11/28 03:05:27 UTC
(james-project) 05/05: JAMES-2586 - Optimize `PostgresUsersDAO.listReactive` method
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch postgresql
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 719277ce83cc010a647bb5bbae61db83ee4e0ed5
Author: TungTV <vt...@linagora.com>
AuthorDate: Thu Nov 28 09:05:41 2024 +0700
JAMES-2586 - Optimize `PostgresUsersDAO.listReactive` method
---
.../java/org/apache/james/user/postgres/PostgresUsersDAO.java | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/server/data/data-postgres/src/main/java/org/apache/james/user/postgres/PostgresUsersDAO.java b/server/data/data-postgres/src/main/java/org/apache/james/user/postgres/PostgresUsersDAO.java
index 04c53d38a2..b28645f666 100644
--- a/server/data/data-postgres/src/main/java/org/apache/james/user/postgres/PostgresUsersDAO.java
+++ b/server/data/data-postgres/src/main/java/org/apache/james/user/postgres/PostgresUsersDAO.java
@@ -20,6 +20,7 @@
package org.apache.james.user.postgres;
import static org.apache.james.backends.postgres.utils.PostgresExecutor.DEFAULT_INJECT;
+import static org.apache.james.backends.postgres.utils.PostgresExecutor.EAGER_FETCH;
import static org.apache.james.user.postgres.PostgresUserModule.PostgresUserTable.ALGORITHM;
import static org.apache.james.user.postgres.PostgresUserModule.PostgresUserTable.AUTHORIZED_USERS;
import static org.apache.james.user.postgres.PostgresUserModule.PostgresUserTable.DELEGATED_USERS;
@@ -32,7 +33,6 @@ import static org.jooq.impl.DSL.count;
import java.util.Iterator;
import java.util.Optional;
-import java.util.function.Function;
import jakarta.inject.Inject;
import jakarta.inject.Named;
@@ -141,10 +141,9 @@ public class PostgresUsersDAO implements UsersDAO {
@Override
public Flux<Username> listReactive() {
- return postgresExecutor.executeRows(dslContext -> Flux.from(dslContext.selectFrom(TABLE_NAME)))
- .map(record -> Username.of(record.get(USERNAME)))
- .collectList()
- .flatMapIterable(Function.identity());
+ return postgresExecutor.executeRows(dslContext -> Flux.from(dslContext.select(USERNAME)
+ .from(TABLE_NAME)), EAGER_FETCH)
+ .map(record -> Username.of(record.get(USERNAME)));
}
@Override
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org