I am trying to use PostgreSQL for a financial system and I need the best performance I can use, so I decided to use stored procedures for managing all the math and logic of the system. I have read that luajit have performance similar to C but without the "dangers" of using C.

Fortunately PostgreSQL has lua as one of its procedural languages but I don't know if this pl/lua is luajit or only lua (and therefore the performance associated to them).

So if PostgreSQL uses lua performance I would use pl/v8 instead but if pl/lua uses luajit I will stay with pl/lua.


According to Luis Carvalho, one of the developers of PL/Lua, PL/Lua can use LuaJIT.

However, you may find there are many more factors which affect the overall performance of the PL code you write, including the overhead of the language's bindings in PostgreSQL, data type conversions, familiarity of your developers with Lua vs. other languages and their ability to write performant code, and many more. There's some more discussion about performance of the PLs you may find interesting.

PL/Lua did do well in a benchmark done by Pavel Stehule.

  • Thank you so much for the links. I am not sure how can I use LuaJIT, I have to import something?, install something? How can I tell if I am using LuaJIT instead of Lua?
    – Lben
    May 19 '15 at 3:06
  • I'm not sure I can help much in installation procedures, but there's an example in the PL/Lua documentation under "Anonymous blocks" doing local ffi = assert(require("ffi")); -- LuaJIT which AFAICT would ensure you are actually using LuaJIT. May 19 '15 at 17:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.