FG
🗄️ Databases

Hydration performance issue on complex dataset

Freshalmost 4 years ago
Mar 14, 20260 views
Confidence Score80%
80%

Problem

Issue type: [X] question [ ] bug report [ ] feature request [ ] documentation issue Database system/driver: [ ] `cordova` [ ] `mongodb` [ ] `mssql` [ ] `mysql` / `mariadb` [ ] `oracle` [X] `postgres` [ ] `sqlite` [ ] `sqljs` [ ] `react-native` TypeORM version: [ ] `latest` [ ] `@next` [X] `0.2.6` *Steps to reproduce or a small repository showing the problem: Hi, we have a performance issue in hydration for a (quite) complex query like this: [code block] This generates a SQL query like the following: [code block] The SQL query in our development database takes approximately 32ms and returns a raw resultset of approx 4400 rows, as you can see it's very fast. On the other hand the hydration process takes approx 4500ms running inside an hi-end Intel I7 CPU. Have you any clues why the hydration process takes so long ? Could be something related to the entities config ? Thanks in adavnce for your help, Leonardo

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
77% confidence100% success rate5 verificationsLast verified Mar 14, 2026

Solution: Hydration performance issue on complex dataset

Low Risk

Ok, we are actually hitting the same problem right now. The worst part of this is that it's blocking our server (the nestjs thread) and I have no clue why. We have the same kind of architecture and complexity as @leoperria . Edit: So more info on this. After digging a bit the issue comes from the `RawSqlResultsToEntityTransformer.transform()` method. The massive use of find, map and other ope

77

Trust Score

5 verifications

100% success
  1. 1

    Ok, we are actually hitting the same problem right now. The worst part of this i

    Ok, we are actually hitting the same problem right now. The worst part of this is that it's blocking our server (the nestjs thread) and I have no clue why.

  2. 2

    We have the same kind of architecture and complexity as @leoperria .

    We have the same kind of architecture and complexity as @leoperria .

  3. 3

    So more info on this. After digging a bit the issue comes from the `RawSqlResult

    So more info on this. After digging a bit the issue comes from the `RawSqlResultsToEntityTransformer.transform()` method.

  4. 4

    The massive use of find, map and other operators is probably the root cause. But

    The massive use of find, map and other operators is probably the root cause. But the side effect is that all this is synchronous, meaning it's blocking.

Validation

Resolved in typeorm/typeorm GitHub issue #2381. Community reactions: 10 upvotes.

Verification Summary

Worked: 5
Partial: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

typeormormtypescriptquestionperformancedriver:-postgres