How does Prisma ORM build select Top in SQL Server?

My problem, can reply this query SELECT TOP 1000 * FROM [User] ORDER BY [id] ASC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY; I have a question about how Prisma builds queries with TOP. In the code below, which of the SQL statements will Prisma execute in the SQL Server database? const users = await prisma.user.findMany({ take: 10, }); Option 1 SELECT TOP 10 * FROM [User]; Option 2 SELECT * FROM [User] ORDER BY [id] ASC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;
2 Replies
Prisma AI Help
Prisma AI Help•2w ago
You're in no rush, so we'll let a dev step in. Enjoy your coffee, or drop into #ask-ai if you get antsy for a second opinion!
Nurul
Nurul•7d ago
Hey 👋 You can find the exact SQL query generated by enabling query logging https://www.prisma.io/docs/orm/prisma-client/observability-and-logging/logging#log-to-stdout
Logging | Prisma Documentation
Learn how to configure Prisma Client to log the raw SQL queries it sends to the database and other information.

Did you find this page helpful?