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

perf: remove json_typeof #3316

Merged
merged 2 commits into from
Mar 8, 2024
Merged

perf: remove json_typeof #3316

merged 2 commits into from
Mar 8, 2024

Conversation

steve-chavez
Copy link
Member

@steve-chavez steve-chavez commented Mar 8, 2024

Closes #2676. Removes json_typeof/jsonb_typeof by using some light validation on the json body using lazy bytestring functions.

  • grants ~10% perf increase.
    • can be confirmed with the PlanSpec change.
    • can be confirmed manually with pgbench like:
$ postgrest-with-postgresql-16 -f test/pgbench/fixtures.sql pgbench -U postgres -n -T 10 -f test/pgbench/2676/old.sql 
tps = 3480.654744 (without initial connection time)

$ postgrest-with-postgresql-16 -f test/pgbench/fixtures.sql pgbench -U postgres -n -T 10 -f test/pgbench/2676/new.sql 
tps = 3973.138881 (without initial connection time)
  • memory usage is kept the same
  • no need for a new content-type as per a previous idea on Optimizations for INSERT #2676. This is an improvement for every write case.

@steve-chavez
Copy link
Member Author

steve-chavez commented Mar 8, 2024

grants ~14% perf increase.

The above is true in pure SQL. But I haven't been able to reproduce a notable gain through http calls.

# Using https://github.com/PostgREST/postgrest-benchmark

$ postgrest-bench-k6 10 k6/POSTBulk.js # with 12.0.2

    http_reqs..................: 25959  822.396728/s

$ postgrest-bench-k6 10 k6/POSTBulk.js # with this PR

    http_reqs..................: 28556  906.419157/s

The loadtest in CI also shows the same.

@wolfgangwalther
Copy link
Member

But I haven't been able to reproduce a notable gain through http calls.

822/s vs 906/s is about 10% more. What am I missing?

@steve-chavez
Copy link
Member Author

Right, my bad. I was looking at some k6/POSTSingle.js (posts single object) results I had when I finished writing that. There isn't a noticeable gain there. But thinking more about it, it makes sense since json_typeof usage should mostly affect large payloads.

CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: Laurence Isla <lau.isla.c@gmail.com>
@steve-chavez steve-chavez merged commit 650249e into PostgREST:main Mar 8, 2024
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Optimizations for INSERT
3 participants