sequelize-typescript icon indicating copy to clipboard operation
sequelize-typescript copied to clipboard

how to improve findAll operation speed

Open namett3 opened this issue 3 years ago • 4 comments

Issue

l have created the table with index in sqlserver, the table has 6000 data and it include 4 tables, i query it only need 0.2 seconds, but use Model.findAll({include:[tabel1,table2,table3]}) will need 12 seconds ,how can l improve the speed? if use index, hope telling me how to use @index to corresponde the index of table has been created

Versions

  • sequelize: v6
  • sequelize-typescript: v6
  • typescript:

Issue type

  • [ ] bug report
  • [x] feature request

Actual behavior

Expected behavior

Steps to reproduce

Related code

insert short code snippets here

namett3 avatar Dec 16 '21 09:12 namett3

I'm having the same issue when i try to findAll with include all and nested true options it greatly increase the amount of time that it takes to give a result (i have about 10+ relations (oneToOne) in a table and the more i add them to sequelize the slower it takes). I've done some testing removing sequelize-typescript dependency and the speed just comes back to normal. Is there any way to fix this?

laurix-wizard avatar Dec 17 '21 13:12 laurix-wizard

sequelize-typescript doesn't really modify this, if it's the library issue, it's probably down to sequelize, so might be better to check there for support.

Though, would be helpful to share your code snippets and DB setup as it might be down to it.

lukashroch avatar Dec 17 '21 13:12 lukashroch

Yeah, yesterday i was testing again the code (with sequelize-typescript) and it was very fast again to fetch data. So we discarded the idea it was sequelize-typescript. It is kinda crazy some times it takes 8s and in another day takes 200ms, i really wonder whats going on to this to happen.

laurix-wizard avatar Dec 21 '21 12:12 laurix-wizard

@namett3 please try include models with separate: true flag. Maybe it helps you.

sluchznak avatar Feb 17 '22 16:02 sluchznak