From 93b8273aa813f0280af42f0b8a01818824e9247c Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Fri, 5 Jul 2024 17:46:45 +0600 Subject: [PATCH] feat: add faq for accelerate transaction billing #DA-935 (#6140) * feat: add faq for accelerate transaction billing behaviour * Update content/300-accelerate/600-faq.mdx * fix: add performance incentive * Update content/300-accelerate/600-faq.mdx --- content/300-accelerate/600-faq.mdx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/content/300-accelerate/600-faq.mdx b/content/300-accelerate/600-faq.mdx index af0ae9fb72..58ed384dfb 100644 --- a/content/300-accelerate/600-faq.mdx +++ b/content/300-accelerate/600-faq.mdx @@ -125,3 +125,25 @@ In the rare event of a service disruption, falling back to a direct connection w If there is a service disruption, it's recommended to verify on the [status page](https://pris.ly/data-platform-status). You can reach out to one of Prisma's [support channels](/platform/support) for assistance. > **Note:** Additionally, it's worth noting that some edge function runtime environments may not support direct connections with Prisma ORM. For further details, refer to our [Edge functions documentation](/orm/prisma-client/deployment/edge/overview). + +## Are each of the queries within an interactive transaction counted separately for billing? + +Yes, [interactive transactions](/orm/prisma-client/queries/transactions#interactive-transactions) are billed based on the individual operations within the transaction. There is no charge for the start, commit, or rollback of the transaction itself. For example, in the following query, there are two billable queries: + +```ts +await prisma.$transaction(async (tx) => { + await tx.user.deleteMany({ where: { name: 'John Doe' } }); + await tx.user.createMany({ data }); +}); +``` + +However, when using the [`$transaction` API for sequential client operations](/orm/prisma-client/queries/transactions#sequential-prisma-client-operations), regardless of the number of queries within the array, it counts as only one billable query. For example: + +```ts +await prisma.$transaction([ + prisma.user.deleteMany({ where: { name: 'John Doe' } }), + prisma.user.createMany({ data }), +]); +``` + +If you don't need [interactive transactions](/orm/prisma-client/queries/transactions#interactive-transactions), you can save costs and improve performance by using [sequential operations transactions](/orm/prisma-client/queries/transactions#sequential-prisma-client-operations). Sequential operations transactions perform better on Accelerate because they execute in one round-trip to the database, while interactive transactions require separate round-trips for start, commit, and each individual operation on the transaction. \ No newline at end of file