Skip to content

fix(join): properly coerce json list#4690

Merged
Weakky merged 3 commits intomainfrom
fix/join-json-list
Jul 31, 2024
Merged

fix(join): properly coerce json list#4690
Weakky merged 3 commits intomainfrom
fix/join-json-list

Conversation

@Weakky
Copy link
Copy Markdown
Contributor

@Weakky Weakky commented Feb 2, 2024

Overview

fixes prisma/prisma#22923

@Weakky Weakky requested a review from a team as a code owner February 2, 2024 13:29
@Weakky Weakky requested review from laplab and miguelff and removed request for a team February 2, 2024 13:29
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 2, 2024

WASM Query Engine file Size

Engine This PR Base branch Diff
Postgres 2.057MiB 2.057MiB 337.000B
Postgres (gzip) 820.817KiB 820.453KiB 373.000B
Mysql 2.028MiB 2.027MiB 337.000B
Mysql (gzip) 808.164KiB 808.035KiB 132.000B
Sqlite 1.919MiB 1.919MiB 0.000B
Sqlite (gzip) 766.278KiB 766.277KiB 1.000B

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 2, 2024

✅ WASM query-engine performance won't change substantially (1.004x)

Full benchmark report
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/bench?schema=imdb_bench&sslmode=disable" \
node --experimental-wasm-modules query-engine/driver-adapters/executor/dist/bench.mjs
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
cpu: AMD EPYC 7763 64-Core Processor
runtime: node v18.19.1 (x64-linux)

benchmark                   time (avg)             (min … max)       p75       p99      p999
-------------------------------------------------------------- -----------------------------
• movies.findMany() (all - ~50K)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline     289 ms/iter       (285 ms … 293 ms)    291 ms    293 ms    293 ms
Web Assembly: Latest       370 ms/iter       (369 ms … 371 ms)    370 ms    371 ms    371 ms
Web Assembly: Current      372 ms/iter       (370 ms … 373 ms)    373 ms    373 ms    373 ms
Node API: Current          206 ms/iter       (191 ms … 218 ms)    215 ms    218 ms    218 ms

summary for movies.findMany() (all - ~50K)
  Web Assembly: Current
   1.8x slower than Node API: Current
   1.29x slower than Web Assembly: Baseline
   1.01x slower than Web Assembly: Latest

• movies.findMany({ take: 2000 })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline  11'522 µs/iter (11'225 µs … 14'210 µs) 11'361 µs 14'210 µs 14'210 µs
Web Assembly: Latest    15'058 µs/iter (14'660 µs … 16'511 µs) 15'094 µs 16'511 µs 16'511 µs
Web Assembly: Current   15'148 µs/iter (14'937 µs … 16'291 µs) 15'149 µs 16'291 µs 16'291 µs
Node API: Current        7'947 µs/iter   (7'833 µs … 8'115 µs)  7'979 µs  8'115 µs  8'115 µs

summary for movies.findMany({ take: 2000 })
  Web Assembly: Current
   1.91x slower than Node API: Current
   1.31x slower than Web Assembly: Baseline
   1.01x slower than Web Assembly: Latest

• movies.findMany({ where: {...}, take: 2000 })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   1'847 µs/iter   (1'756 µs … 2'776 µs)  1'839 µs  2'556 µs  2'776 µs
Web Assembly: Latest     2'401 µs/iter   (2'310 µs … 3'218 µs)  2'397 µs  2'953 µs  3'218 µs
Web Assembly: Current    2'429 µs/iter   (2'334 µs … 3'121 µs)  2'421 µs  3'063 µs  3'121 µs
Node API: Current        1'388 µs/iter   (1'314 µs … 1'790 µs)  1'398 µs  1'599 µs  1'790 µs

summary for movies.findMany({ where: {...}, take: 2000 })
  Web Assembly: Current
   1.75x slower than Node API: Current
   1.32x slower than Web Assembly: Baseline
   1.01x slower than Web Assembly: Latest

• movies.findMany({ include: { cast: true } take: 2000 }) (m2m)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline     551 ms/iter       (544 ms … 569 ms)    564 ms    569 ms    569 ms
Web Assembly: Latest       732 ms/iter       (726 ms … 749 ms)    747 ms    749 ms    749 ms
Web Assembly: Current      729 ms/iter       (725 ms … 741 ms)    735 ms    741 ms    741 ms
Node API: Current          451 ms/iter       (443 ms … 470 ms)    467 ms    470 ms    470 ms

summary for movies.findMany({ include: { cast: true } take: 2000 }) (m2m)
  Web Assembly: Current
   1.62x slower than Node API: Current
   1.32x slower than Web Assembly: Baseline
   1x faster than Web Assembly: Latest

• movies.findMany({ where: {...}, include: { cast: true } take: 2000 }) (m2m)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline  76'495 µs/iter (75'827 µs … 78'701 µs) 76'503 µs 78'701 µs 78'701 µs
Web Assembly: Latest       102 ms/iter       (102 ms … 103 ms)    103 ms    103 ms    103 ms
Web Assembly: Current      103 ms/iter       (102 ms … 104 ms)    103 ms    104 ms    104 ms
Node API: Current       60'167 µs/iter (59'824 µs … 60'610 µs) 60'381 µs 60'610 µs 60'610 µs

summary for movies.findMany({ where: {...}, include: { cast: true } take: 2000 }) (m2m)
  Web Assembly: Current
   1.71x slower than Node API: Current
   1.34x slower than Web Assembly: Baseline
   1x faster than Web Assembly: Latest

• movies.findMany({ take: 2000, include: { cast: { include: { person: true } } } })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline     979 ms/iter     (972 ms … 1'000 ms)    979 ms  1'000 ms  1'000 ms
Web Assembly: Latest     1'216 ms/iter   (1'204 ms … 1'240 ms)  1'239 ms  1'240 ms  1'240 ms
Web Assembly: Current    1'213 ms/iter   (1'206 ms … 1'237 ms)  1'216 ms  1'237 ms  1'237 ms
Node API: Current          883 ms/iter       (852 ms … 908 ms)    902 ms    908 ms    908 ms

summary for movies.findMany({ take: 2000, include: { cast: { include: { person: true } } } })
  Web Assembly: Current
   1.37x slower than Node API: Current
   1.24x slower than Web Assembly: Baseline
   1x faster than Web Assembly: Latest

• movie.findMany({ where: { ... }, take: 2000, include: { cast: { include: { person: true } } } })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline     138 ms/iter       (137 ms … 139 ms)    138 ms    139 ms    139 ms
Web Assembly: Latest       169 ms/iter       (169 ms … 170 ms)    169 ms    170 ms    170 ms
Web Assembly: Current      169 ms/iter       (169 ms … 173 ms)    170 ms    173 ms    173 ms
Node API: Current          104 ms/iter       (103 ms … 106 ms)    106 ms    106 ms    106 ms

summary for movie.findMany({ where: { ... }, take: 2000, include: { cast: { include: { person: true } } } })
  Web Assembly: Current
   1.62x slower than Node API: Current
   1.23x slower than Web Assembly: Baseline
   1x faster than Web Assembly: Latest

• movie.findMany({ where: { reviews: { author: { ... } }, take: 100 }) (to-many -> to-one)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline     872 µs/iter     (816 µs … 1'496 µs)    868 µs  1'368 µs  1'496 µs
Web Assembly: Latest     1'222 µs/iter   (1'150 µs … 1'814 µs)  1'214 µs  1'645 µs  1'814 µs
Web Assembly: Current    1'224 µs/iter   (1'156 µs … 1'778 µs)  1'220 µs  1'676 µs  1'778 µs
Node API: Current          788 µs/iter     (702 µs … 1'355 µs)    802 µs  1'124 µs  1'355 µs

summary for movie.findMany({ where: { reviews: { author: { ... } }, take: 100 }) (to-many -> to-one)
  Web Assembly: Current
   1.55x slower than Node API: Current
   1.4x slower than Web Assembly: Baseline
   1x faster than Web Assembly: Latest

• movie.findMany({ where: { cast: { person: { ... } }, take: 100 }) (m2m -> to-one)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline     864 µs/iter     (819 µs … 1'518 µs)    867 µs  1'227 µs  1'518 µs
Web Assembly: Latest     1'196 µs/iter   (1'149 µs … 1'751 µs)  1'203 µs  1'492 µs  1'751 µs
Web Assembly: Current    1'209 µs/iter   (1'162 µs … 1'662 µs)  1'217 µs  1'503 µs  1'662 µs
Node API: Current          770 µs/iter     (709 µs … 1'051 µs)    792 µs    917 µs  1'051 µs

summary for movie.findMany({ where: { cast: { person: { ... } }, take: 100 }) (m2m -> to-one)
  Web Assembly: Current
   1.57x slower than Node API: Current
   1.4x slower than Web Assembly: Baseline
   1.01x slower than Web Assembly: Latest

After changes in 9eea31a

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Feb 2, 2024

CodSpeed Performance Report

Merging #4690 will not alter performance

Comparing fix/join-json-list (9eea31a) with main (af6ceee)

Summary

✅ 11 untouched benchmarks

@aqrln aqrln added this to the 5.10.0 milestone Feb 9, 2024
@aqrln aqrln modified the milestones: 5.10.0, 5.11.0 Feb 20, 2024
@Weakky Weakky force-pushed the fix/join-json-list branch from 9eea31a to cb276b4 Compare July 31, 2024 10:27
@Weakky Weakky modified the milestones: 5.11.0, 5.18.0 Jul 31, 2024
@Weakky Weakky merged commit b438c24 into main Jul 31, 2024
@Weakky Weakky deleted the fix/join-json-list branch July 31, 2024 13:08
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.

empty Json[] fields turn to null (instead of an empty []) when accessed through a join using the new relationJoins feature

2 participants