Skip to content

.limit() performance regression in v0.3.29 #12445

Closed

Description

@cduff

Issue description

.limit() unexpectedly causing 2 queries with Select using Query Builder

Expected Behavior

createQueryBuilder("child")
  .innerJoinAndSelect("child.parent", "parent")
  .offset(2)
  .limit(2)
  .getMany()

Using v0.3.28 this worked by generating a single query with OFFSET and LIMIT clauses (MySQL).

Actual Behavior

Using v0.3.29 the above now generates two queries - one to get distinct IDs and another to get the desired results.

This causes a performance and behaviour regression. Some queries I tested roughly doubled in total execution time.

Steps to reproduce

Any simple query as above.

My Environment

Dependency Version
Operating System Windows 11 Pro
Node.js version 24.15.0
Typescript version 6.0.3
TypeORM version 0.3.29

Additional Context

Firstly, thanks for your efforts on TypeORM!

The source of this issue looks to be #11987. @gioboa.

Should this change have been noted in the release notes?

My understanding from the TypeORM documentation is that offset and limit behave on the underlying query result set like the MySQL OFFSET and LIMIT clauses.

In contrast, QueryBuilder also supports pagination using take and skip, which understandably requires the 2-step query process.

The change made in v0.3.29 seem to break the power of offset and limit and duplicate the take and skip feature?

As the advanced query building interface of TypeORM, I'd think QueryBuilder should support generating single-query OFFSET LIMIT queries.

Relevant Database Driver(s)

  • aurora-mysql
  • aurora-postgres
  • better-sqlite3
  • capacitor
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • spanner
  • sqlite
  • sqljs
  • sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.

Activity

  1. dalexander-trc commented on May 14, 2026

    @dalexander-trc

    When can we expect this fix/rollback to go live? Wondering if we need to pin our repos to 0.3.28 until this is deployed.

  2. gioboa commented on May 14, 2026

    @gioboa
    Collaborator

    If you are affected by this regression, as you mentioned, the best solution is to pin that version and wait the next patch release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions