Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Slow startup time when creating a new client #536

Closed
gibsonjoshua55 opened this issue Feb 29, 2020 · 5 comments
Closed

Slow startup time when creating a new client #536

gibsonjoshua55 opened this issue Feb 29, 2020 · 5 comments
Labels
bug/0-needs-info More information is needed for reproduction. kind/bug A reported bug. status/needs-action Issue has no activity for a long time, needs some action. topic: performance

Comments

@gibsonjoshua55
Copy link

I just started using the prisma client and I started a small project following the Getting Started guide. After introspecting my database, I copied in the script from the docs and ran it with ts-node; however, it takes about 50 seconds for the line const prisma = new PrismaClient(); to execute. The database introspected has a decent amount of tables, but nothing crazy. Is it normal for this step take this long on every start up?

Details

  • script.ts
import { PrismaClient } from '@prisma/client';
console.log("started");
const prisma = new PrismaClient();
console.log("created");
async function main() {
  const users = await prisma.loop_user.findMany({
    where: {
      email: {
        contains: "maadmin"
      }
    }
  });
  console.log(JSON.stringify(users));
}

main()
  .catch(e => {
    throw e;
  })
  .finally(async () => {
    await prisma.disconnect();
  });
  • package.json
{
  "name": "prisma-test",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "start": "ts-node src/script.ts"
  },
  "devDependencies": {
    "@types/node": "^13.7.7",
    "prisma2": "2.0.0-preview022",
    "ts-node": "^8.6.2",
    "typescript": "^3.8.3"
  },
  "dependencies": {
    "@prisma/client": "2.0.0-preview022"
  }
}
@janpio
Copy link
Member

janpio commented Feb 29, 2020

We are aware of some problems with the size, which can also affect the loading time: #524

Can you share the number of tables of your schema?
Or possibly even the schema itself? (If you can not share it publicly, we are happy to sign an NDA: prisma/prisma#757 Having actual real world schemas that show specific problems makes it much easier for us to reproduce and optimize)

@gibsonjoshua55
Copy link
Author

We have 94 tables in our schema. I'll chat with my manager about sharing the schema. We'd love to help optimize the project!

@pantharshit00 pantharshit00 added bug/0-needs-info More information is needed for reproduction. kind/improvement An improvement to existing feature and code. labels Mar 1, 2020
@timsuchanek
Copy link
Contributor

timsuchanek commented Mar 5, 2020

@gibsonjoshua55 please try out the latest alpha - we did a major improvement, which should reduce the loading time a lot!

npm install @prisma/client@alpha

@janpio janpio added kind/bug A reported bug. and removed kind/improvement An improvement to existing feature and code. labels Mar 15, 2020
@janpio
Copy link
Member

janpio commented Mar 15, 2020

Did the recent releases improve the situation @gibsonjoshua55?

@stale stale bot added the status/needs-action Issue has no activity for a long time, needs some action. label Jul 25, 2020
@timsuchanek
Copy link
Contributor

Closing this due to inactivity

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug/0-needs-info More information is needed for reproduction. kind/bug A reported bug. status/needs-action Issue has no activity for a long time, needs some action. topic: performance
Projects
None yet
Development

No branches or pull requests

4 participants