Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

293
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda