Choose Between PSQL, Wasm-based, and External Functions
On this page
The decision whether to use Procedural SQL (PSQL) functions, Wasm-based functions, and external functions depends on the specific functionality and performance requirements of each implementation.
SingleStore recommends using PSQL functions to implement database logic and Wasm-based functions for complex or existing C/C++ or Rust code.
Using PSQL Functions
For standard SQL operations, procedural logic, and performance-critical implementations, SingleStore recommends using PSQL functions.
Using Wasm-based Functions
Use Wasm-based functions to implement complex logic, data structures, or existing C/C++ or Rust code.
Wasm-based functions in SingleStore do not support runtime capabilities that the database does not provide out of the box, such as making system calls, opening files, opening sockets, sending network messages, creating processes, or creating threads.
Using External Functions
Use external functions to execute logic that cannot be implemented within the database, when the language isn't supported by Wasm (C#, Java, Python, etc.
External functions may have a higher overhead (higher resource costs or lower performance) than PSQL or Wasm-based functions because of network latency and the resource costs associated with serializing and deserializing data between SingleStore and external services.
Summary
The following table summarizes the recommended use case and limitation of each function type:
Function Type |
Description |
Recommended Use Case |
Limitation |
---|---|---|---|
Procedural SQL (PSQL) |
Runs SQL or PSQL code within the SingleStore engine |
Standard SQL operations, procedural logic, and performance-critical implementations |
|
Wasm-based |
Imports existing C/C++ or Rust code and runs the code within the SingleStore engine |
Implement complex data structures using C/C++ or Rust |
|
External |
Calls a function that runs outside of the SingleStore engine |
|
|
Last modified: August 14, 2024