perf(postgrest): optimize select column normalization#2334
Conversation
@supabase/auth-js
@supabase/functions-js
@supabase/postgrest-js
@supabase/realtime-js
@supabase/storage-js
@supabase/supabase-js
commit: |
|
Hello @astelmach01, thanks for taking the time to dig into this and for the thorough benchmark. Before going further, I want to ask one thing: did you hit If you've got a real-world profile where this shows up (a tight loop, a server building many queries per request, anything like that) I'd love to see it and I'll happily reconsider. Otherwise I think I am a bit reluctant to go forward with this change, as it adds in complexity. Either way, genuinely appreciate the contribution and the care you put into the PR. |
Summary
select()column cleanup with a single-pass implementation that avoidssplit/map/joinallocations.Performance
Local microbenchmark on Node v23.7.0, 1,000,000 iterations per case:
*: 68.1ms -> 12.9ms, 5.27x fasterid,name,email,created_at: 679.8ms -> 285.7ms, 2.38x fasterValidation
npx jest test/query-builder.test.ts --runInBandnpm run type-check --workspace=@supabase/postgrest-jsnpx prettier --check packages/core/postgrest-js/src/PostgrestQueryBuilder.ts packages/core/postgrest-js/test/query-builder.test.tsNote: full
npm run format:check --workspace=@supabase/postgrest-jscurrently reports an unrelated existing formatting issue inpackages/core/postgrest-js/test/rpc.test.ts.