wasmerio / wasmer-postgres

💽🕸 Postgres library to run WebAssembly binaries.

Home Page:https://medium.com/wasmer/announcing-the-first-postgres-extension-to-run-webassembly-561af2cfcb1

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Benchmark overflows

tvenhola opened this issue · comments

Benchmark (as published on medium.com) has several issues:

  • int32 overflows: 48th fibonacci number is larger than 2^31
  • plpgsql version uses decimal, which is a different datatype (infinite length and precision numeric) and does not overflow, i.e. benchmark is comparing apples to oranges
  • Apparently no correctness checks were performed for the returned value, allowing the function to be quick by returning incorrect values and not catching errors

Instead of the current plpgsql implementation like this could (should) be used
with recursive r(a, b, c) as ( select 0::int, 1::int, 1::int union all select b, a + b, c+1::int from r where c < 46 ) select a from r where c = 45;

Thanks, I'll try!