nestjs typeorm get number of rows

Viewed 570

I'm working on a project, and I'm using the getManyAndCount() function of typeorm.

However, this function executes two queries: a query to get a result + a count(*) query.

So it takes twice as long as I thought.

For performance, I found SQL_CALC_FOUND_ROWS while doing a Google search. It seems to be the usage of mysql, is there a way to use this in typeorm?

If this is not a good way, please tell me another quick way.

thank you!

Below is an example of the currently used querybuilder.


this.catRepository('cat')
.select('cat.id','id)
.addSelect('cat.name','name')
.addSelect('cat.age','age')
...
.innerJoin(...)
.innerJoin(...)
.getManyAndCount()
...
0 Answers
Related