Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create method performance issues. #5474

Closed
yousufhasan opened this issue Feb 4, 2021 · 7 comments
Closed

create method performance issues. #5474

yousufhasan opened this issue Feb 4, 2021 · 7 comments
Labels
bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug. team/client Issue for team Client. topic: performance

Comments

@yousufhasan
Copy link

yousufhasan commented Feb 4, 2021

When passing a very large object e.g. 1 million records with many sub entities to create method. It doesn't start running queries for few minutes and only after taking few minutes it starts running the queries. I can't see any thing on my terminal until after few minutes which impacts the performance badly. It doesn't take that longer if the object size is smaller.

proivder: postgresql
binaryTargets = ["native", "linux-musl"]

Version: PostgreSQL 13.1 (Debian 13.1-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit

@Jolg42
Copy link
Member

Jolg42 commented Feb 8, 2021

Related #5475

@pantharshit00
Copy link
Contributor

Hey @yousufhasan

Was this working in older version?

Please try enabling unix domain socket transport once for data between prisma engine. Here is how you can do that:

const prisma = new PrismaClient({
  __internal:{
    useUds: true
  }
} as any); // remove as any if you are using js

@Jolg42
Copy link
Member

Jolg42 commented Feb 8, 2021

I would be interesting to confirm which version of Prisma you are running, from #5475 it seems it's 2.16.0?

@pantharshit00 pantharshit00 added bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug. topic: performance team/client Issue for team Client. labels Feb 8, 2021
@yousufhasan
Copy link
Author

Still getting the error:
"Error: Invalid prisma.aspData.create() invocation: connect ECONNREFUSED /tmp/prisma-c6e52d6e564849db55f91ce1.sock"

Yes the version is 2.16.0

@pantharshit00
Copy link
Contributor

Ok, this seems unrelated to uds. Would it be possible for you share your schema here so that we can look into the data structure and try reproducing this?

@yousufhasan
Copy link
Author

yousufhasan commented Feb 10, 2021

Here is the data, You can duplicate it like 20,000 organizations each having 20 metas and 20 subOrganisations each having 15 metas.

Apart from getting this error the other issue is because createMany doesn't work with nesting and create generates single query for each record. the performance is very bad when we compare it with other ORMs like TypeORM. also since $transactions doesn't support dependent entities we can not do it inside transactions as well. That is why support of nested queries with createMany is essential.

{
  "code": "3434",
  "name": "test1",
  "createdDate": "2021-02-10T01:06:45.074Z",
  "updatedDate": "2021-02-10T01:06:45.074Z",
  "organisations": {
    "create": [
      {
        "name": "test1",
        "createdDate": "2021-02-10T01:06:45.074Z",
        "updatedDate": "2021-02-10T01:06:45.074Z",
        "metas": {
          "createMany": {
            "data": [
              {
                "key": "dfdffd",
                "value": "dfdff",
                "createdDate": "2021-02-10T01:06:45.074Z",
                "updatedDate": "2021-02-10T01:06:45.074Z"
              },
              {
                "key": "dfdffd",
                "value": "dfdff",
                "createdDate": "2021-02-10T01:06:45.074Z",
                "updatedDate": "2021-02-10T01:06:45.074Z"
              }
            ]
          }
        },
        "subOrginsations": {
          "create": [
            {
              "name": "test1",
              "createdDate": "2021-02-10T01:06:45.074Z",
              "updatedDate": "2021-02-10T01:06:45.074Z",
              "metas": {
                "createMany": {
                  "data": [
                    {
                      "key": "dfdffd",
                      "value": "dfdff",
                      "createdDate": "2021-02-10T01:06:45.074Z",
                      "updatedDate": "2021-02-10T01:06:45.074Z"
                    },
                    {
                      "key": "dfdffd",
                      "value": "dfdff",
                      "createdDate": "2021-02-10T01:06:45.074Z",
                      "updatedDate": "2021-02-10T01:06:45.074Z"
                    }
                  ]
                }
              }
            }
          ]
        }
      }
    ]
  }
}

@pantharshit00
Copy link
Contributor

We have a createMany method now which addressed this. I am going to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug. team/client Issue for team Client. topic: performance
Projects
None yet
Development

No branches or pull requests

3 participants