Hi there! I am asking again with regard to the que...
# orm-help
o
Hi there! I am asking again with regard to the query performance. When using
prisma.create
:
Copy code
await this.prisma.statement.create({
      data: {
        contextId,
        content: statementData.content,
      },
    });
It seems that prisma sends two SQL queries to database:
Copy code
prisma:query INSERT INTO "public"."Statement" ("content","contextId","createdAt") VALUES ($1,$2,$3) RETURNING "public"."Statement"."id"

prisma:query SELECT "public"."Statement"."id", "public"."Statement"."content", "public"."Statement"."contextId", "public"."Statement"."createdAt" FROM "public"."Statement" WHERE "public"."Statement"."id" = $1 LIMIT $2 OFFSET $3
Is there a way to exclude sending a second query in this scenario?
r
@Oleg Yarin 👋 For the first query, Prisma always returns the data back after a
create
. For an update, the first statement is unnecessary, and we will be looking into this as per this request 🙂
o
@Ryan For the create part. Why does prisma client sends a second query?
Copy code
SELECT "public"."Statement"."id", "public"."Statement"."content", "public"."Statement"."contextId", "public"."Statement"."createdAt" FROM "public"."Statement" WHERE "public"."Statement"."id" = $1 LIMIT $2 OFFSET $3
? if it always has all the data after the first query (that contains
RETURNING
) I would assume the second one is obsolete
r
The
returning
would most likely be removed, but you can check this request for more info.