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

feat: query compiler proof of concept #5024

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from
Draft

feat: query compiler proof of concept #5024

wants to merge 38 commits into from

Conversation

aqrln
Copy link
Member

@aqrln aqrln commented Oct 25, 2024

Separate query planning and execution and lower the query graph into a format executable by the client.

Translates, for example,

  prisma.user.findMany({
    where: {
      createdAt: {
        gt: Prisma.Param('startDate'),
      },
    },
  })

to

{
  query {
    SELECT `main`.`User`.`id`, `main`.`User`.`email`, `main`.`User`.`createdAt` FROM `main`.`User` WHERE `main`.`User`.`createdAt` > ? LIMIT ? OFFSET ?
  } with [Placeholder { name: "startDate", type: Date }, Int(-1), BigInt(0)];
}

which is then executed by the QueryInterpeter on the client.

Processing query graphs with more than one node is work in progress. Functions in the edges (data dependencies) can be executed at compile time thanks to the new Placeholder abstraction (we can algebraically substitute future values not yet fetched from the database into the inputs of downstream graph nodes and continue building the query with them before those values actually exist). Flow and computation nodes need to be redesigned though.

Client: prisma/prisma#25511

Copy link
Contributor

github-actions bot commented Oct 25, 2024

WASM Query Engine file Size

Engine This PR Base branch Diff
Postgres 1.262MiB 2.044MiB -800.954KiB
Postgres (gzip) 505.784KiB 821.587KiB -315.804KiB
Mysql 1.238MiB 2.011MiB -791.441KiB
Mysql (gzip) 497.952KiB 808.684KiB -310.733KiB
Sqlite 1.217MiB 1.910MiB -709.772KiB
Sqlite (gzip) 488.534KiB 769.892KiB -281.359KiB

Copy link

codspeed-hq bot commented Oct 26, 2024

CodSpeed Performance Report

Merging #5024 will not alter performance

Comparing compiler (6b19a39) with main (cc0167b)

Summary

✅ 11 untouched benchmarks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant