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

fix(sqlserver): Fix max bind values of SQL Server for chunking in simple cases #4747

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

janpio
Copy link
Member

@janpio janpio commented Feb 20, 2024

according to https://stackoverflow.com/a/8050474

This only improves the situation for the most simple cases, but at least those now work. We will have to do more in the future to fix the problem fundamentally.

part of prisma/prisma#18203

Copy link
Contributor

github-actions bot commented Feb 20, 2024

WASM Query Engine file Size

Engine This PR Base branch Diff
Postgres 2.130MiB 2.130MiB 0.000B
Postgres (gzip) 838.788KiB 838.788KiB 0.000B
Mysql 2.098MiB 2.098MiB 0.000B
Mysql (gzip) 825.533KiB 825.533KiB 0.000B
Sqlite 1.991MiB 1.991MiB 0.000B
Sqlite (gzip) 785.918KiB 785.917KiB 2.000B

Copy link

codspeed-hq bot commented Feb 20, 2024

CodSpeed Performance Report

Merging #4747 will not alter performance

Comparing janpio-patch-6 (2347472) with main (e5f3dd7)

Summary

✅ 11 untouched benchmarks

Copy link
Contributor

github-actions bot commented Feb 20, 2024

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

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.20.2 (x64-linux)

benchmark                   time (avg)             (min … max)       p75       p99      p999
-------------------------------------------------------------- -----------------------------
• movies.findMany() (all - ~50K)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline     297 ms/iter       (293 ms … 299 ms)    298 ms    299 ms    299 ms
Web Assembly: Latest       391 ms/iter       (388 ms … 397 ms)    393 ms    397 ms    397 ms
Web Assembly: Current      387 ms/iter       (382 ms … 403 ms)    390 ms    403 ms    403 ms
Node API: Current          200 ms/iter       (198 ms … 204 ms)    204 ms    204 ms    204 ms

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

• movies.findMany({ take: 2000 })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline  11'918 µs/iter (11'595 µs … 14'097 µs) 11'906 µs 14'097 µs 14'097 µs
Web Assembly: Latest    15'632 µs/iter (15'279 µs … 17'323 µs) 15'645 µs 17'323 µs 17'323 µs
Web Assembly: Current   15'392 µs/iter (15'177 µs … 16'989 µs) 15'321 µs 16'989 µs 16'989 µs
Node API: Current        7'999 µs/iter   (7'748 µs … 8'447 µs)  8'041 µs  8'447 µs  8'447 µs

summary for movies.findMany({ take: 2000 })
  Web Assembly: Current
   1.92x slower than Node API: Current
   1.29x slower than Web Assembly: Baseline
   1.02x faster than Web Assembly: Latest

• movies.findMany({ where: {...}, take: 2000 })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   1'859 µs/iter   (1'755 µs … 2'968 µs)  1'846 µs  2'710 µs  2'968 µs
Web Assembly: Latest     2'476 µs/iter   (2'362 µs … 3'978 µs)  2'453 µs  3'198 µs  3'978 µs
Web Assembly: Current    2'439 µs/iter   (2'359 µs … 3'071 µs)  2'443 µs  2'970 µs  3'071 µs
Node API: Current        1'391 µs/iter   (1'303 µs … 1'855 µs)  1'403 µs  1'606 µs  1'855 µs

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

• movies.findMany({ include: { cast: true } take: 2000 }) (m2m)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline     565 ms/iter       (560 ms … 582 ms)    567 ms    582 ms    582 ms
Web Assembly: Latest       762 ms/iter       (755 ms … 779 ms)    765 ms    779 ms    779 ms
Web Assembly: Current      765 ms/iter       (756 ms … 785 ms)    785 ms    785 ms    785 ms
Node API: Current          490 ms/iter       (473 ms … 508 ms)    496 ms    508 ms    508 ms

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

• movies.findMany({ where: {...}, include: { cast: true } take: 2000 }) (m2m)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline  77'773 µs/iter (77'565 µs … 77'910 µs) 77'845 µs 77'910 µs 77'910 µs
Web Assembly: Latest       107 ms/iter       (106 ms … 108 ms)    108 ms    108 ms    108 ms
Web Assembly: Current      107 ms/iter       (106 ms … 108 ms)    108 ms    108 ms    108 ms
Node API: Current       64'037 µs/iter (62'678 µs … 65'207 µs) 65'053 µs 65'207 µs 65'207 µs

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

• movies.findMany({ take: 2000, include: { cast: { include: { person: true } } } })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   1'009 ms/iter   (1'001 ms … 1'024 ms)  1'014 ms  1'024 ms  1'024 ms
Web Assembly: Latest     1'267 ms/iter   (1'260 ms … 1'290 ms)  1'268 ms  1'290 ms  1'290 ms
Web Assembly: Current    1'268 ms/iter   (1'261 ms … 1'297 ms)  1'278 ms  1'297 ms  1'297 ms
Node API: Current          898 ms/iter       (882 ms … 935 ms)    920 ms    935 ms    935 ms

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

• movie.findMany({ where: { ... }, take: 2000, include: { cast: { include: { person: true } } } })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline     142 ms/iter       (141 ms … 144 ms)    144 ms    144 ms    144 ms
Web Assembly: Latest       177 ms/iter       (175 ms … 178 ms)    178 ms    178 ms    178 ms
Web Assembly: Current      182 ms/iter       (180 ms … 183 ms)    183 ms    183 ms    183 ms
Node API: Current          109 ms/iter       (107 ms … 110 ms)    110 ms    110 ms    110 ms

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

• movie.findMany({ where: { reviews: { author: { ... } }, take: 100 }) (to-many -> to-one)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline     870 µs/iter     (815 µs … 1'428 µs)    868 µs  1'285 µs  1'428 µs
Web Assembly: Latest     1'232 µs/iter   (1'168 µs … 1'737 µs)  1'232 µs  1'651 µs  1'737 µs
Web Assembly: Current    1'225 µs/iter   (1'169 µs … 1'831 µs)  1'231 µs  1'758 µs  1'831 µs
Node API: Current          769 µs/iter     (708 µs … 1'056 µs)    797 µs    843 µs  1'056 µs

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

• movie.findMany({ where: { cast: { person: { ... } }, take: 100 }) (m2m -> to-one)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline     859 µs/iter     (817 µs … 1'382 µs)    863 µs  1'185 µs  1'382 µs
Web Assembly: Latest     1'208 µs/iter   (1'151 µs … 1'682 µs)  1'215 µs  1'524 µs  1'682 µs
Web Assembly: Current    1'200 µs/iter   (1'155 µs … 1'834 µs)  1'208 µs  1'582 µs  1'834 µs
Node API: Current          788 µs/iter     (721 µs … 1'150 µs)    808 µs    948 µs  1'150 µs

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

After changes in 2347472

@thedrewguy
Copy link

An improvement, but does not fix root issue - see: prisma/prisma#18203 (comment)

@janpio janpio changed the title fix(sqlserver): Fix max bind values of SQL Server for chunking fix(sqlserver): Fix max bind values of SQL Server for chunking in simple cases Feb 20, 2024
@janpio janpio closed this Apr 23, 2024
@janpio janpio reopened this Apr 23, 2024
@janpio janpio marked this pull request as ready for review April 23, 2024 18:20
@janpio janpio requested a review from a team as a code owner April 23, 2024 18:20
@janpio janpio requested review from Weakky and removed request for a team April 23, 2024 18:20
@janpio janpio added this to the 5.14.0 milestone Apr 23, 2024
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.

None yet

2 participants