Hi everyone ! I’m upgrading to prisma2 but facing ...
# orm-help
l
Hi everyone ! I’m upgrading to prisma2 but facing an issue. One app usecase involves my api making 3 consecutive queries on the same table (with different WHERE params) in my postgres db. If repeating the operation, 2 or 3 times in a row, one database process blows up the cpu usage. I’ve tried to tune the _connection_limit_ param (setting it to 1) with no luck. Could this be related to the query lock mode ? I’m a bit confused by the pg_locks output. Have you already faced something similar ? Thanks prisma team for the great work !
j
Uh this is weird.
Is this database exclusively used by a Prisma 2 application?
What queries are you running?
l
yes it is
here is the generated query :
Copy code
select
	"project$development"."Invoice"."id",
	"project$development"."Invoice"."status",
	"project$development"."Invoice"."paymentMethod",
	"project$development"."Invoice"."dueDate",
	"project$development"."Invoice"."paymentDate",
	"project$development"."Invoice"."description",
	"project$development"."Invoice"."subtotal",
	"project$development"."Invoice"."tax",
	"project$development"."Invoice"."total",
	"project$development"."Invoice"."voidedAt",
	"project$development"."Invoice"."updatedAt",
	"project$development"."Invoice"."createdAt",
	"project$development"."Invoice"."debtor",
	"project$development"."Invoice"."creditor",
	"project$development"."Invoice"."charge"
from
	"project$development"."Invoice"
where
	("project$development"."Invoice"."creditor" = $1
	and "project$development"."Invoice"."enrollment" = $2
	and "project$development"."Invoice"."status" = $3
	and ("project$development"."Invoice"."charge" is null
	or ("project$development"."Invoice"."id") in (
	select
		"t0"."id"
	from
		"project$development"."Invoice" as "t0"
	inner join "project$development"."Charge" as "j0" on
		("j0"."id") = ("t0"."charge")
	where
		("j0"."status" not in ($4,
		$5)
		and "t0"."id" is not null))))
order by
	"project$development"."Invoice"."paymentDate" desc,
	"project$development"."Invoice"."id" asc
limit $6 offset $7
j
l
Is there a way to redirect the logs to files instead of stdout ?
Using query transactions with pgbouncer=true (without even using PgBouncer) seems to help, I’m not able to reproduce that way
j
The Prisma Engine log above (As a file) is missing all queries - so I think this might be cut off.
I think it is time to convert this into an issue - just open a bug report and fill in all the data.
Then we can take a look and ask for any further missing data.
And try to figure this out 👍
👍 1