Skip to content

Commit 00d0be4

Browse files
authored
feat: concurrent queries in paginationDBHelper (#314)
1 parent 2c2dbf6 commit 00d0be4

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/datasources/helpers/paginationQuery.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ export const paginationDBHelper = async <
2828
total: sql<number>`count(*)`,
2929
}).from(subQuery);
3030

31-
// TODO: Considerar parallelizar estas queries en un Promise.all
32-
const totalRecordsResult = await totalRecordsQuery.execute();
33-
const results = await query.limit(safePageSize).offset(offset).execute();
31+
const [totalRecordsResult, results] = await Promise.all([
32+
totalRecordsQuery.execute(),
33+
query.limit(safePageSize).offset(offset).execute(),
34+
]);
3435

3536
const totalRecords = Number(totalRecordsResult[0].total);
3637
const totalPages = Math.ceil(totalRecords / safePageSize);

0 commit comments

Comments
 (0)