Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

287
Views
Typescript is slower than javascript when using sequelize?

I am migrating a web app from javascript to typescript. And I have noticed that the query results are a bit slower sometimes as compared to javascript. It is not consistent though.

I have two tables - User and Team. One user can have many teams. So it is hasMany and belongsTo association between them.

Team Model

import {Model, Table, Column, Default} from 'sequelize-typescript';
@Table
export class Team extends Model {

  @Column name!: string;
  @Default(true)
  @Column isActive!: boolean;
}

User Model

import {Model, Table, Column, Default,DataType} from 'sequelize-typescript';

@Table
export class User extends Model {

  @Column firstName!: string;
  @Column lastName!: string;
  @Column email!: string;
  @Default(true)
  @Column isActivated!: boolean;
  @Column source!: string;
  @Column(DataType.JSON)
  profileData: string;
  @Column(DataType.JSON)
  settings: string;
  @Column(DataType.JSON)
  paymentDetails: string;
}

The association

Team.belongsTo(User, { foreignKey: "fk_ownerId", as: 'Owner' });
User.hasMany(Team, { foreignKey: "fk_ownerId", as: 'OwnedTeams' }); 

Here are my results

30k records

typescript
user ins query: 2.955s
user query: 2.134s

javascript
user ins query: 3.785s
user query: 1.947s

50k records

typescript
team ins query: 4.621s
team query: 2.601s

javascript
team ins query: 4.352s
team query: 2.340s

tsconfig.json

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es6",
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "sourceMap": true,
        "strictNullChecks": false,
        "noUnusedLocals": true,
        "pretty": true,
        "skipLibCheck": true,
        "lib": [
            "es2015"
        ]
    }
}

I am running tsc --build to generate the build. Is there anything that I have been doing wrong ?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!