Is there way to run raw SQL in voltdb python driver(voltdb-client-python)?

263 Views Asked by At

I try to work with voltdb and it's python driver I can create a procedure in voltdb and call it with VoltProcedure. Smth like:

 volt_procedure = VoltProcedure(volt, "Proc_name", [VoltConnection.VOLTTYPE_STRING])

 result = volt_procedure.call(some_argument)

The question is - can I somehow run raw SQL with this driver?

1

There are 1 best solutions below

0
On

Yes, you can call the system procedure "@AdHoc" which takes a String parameter which is the SQL statement you want to run.

All calls to @AdHoc have some additional overhead, since they need to be parsed and either planned, or an existing plan is found in the cache. After that, they are executed exactly like a pre-compiled stored procedure. Each server in the cluster has a pool of threads for parsing and planning, so the capacity to handle @AdHoc calls will scale, but for quick simple SQL statements it is generally lower than the cluster's capacity to execute the transactions. For more complex SQL, it generally takes longer to execute the transaction, so depending on the execution time, the capacity for parsing may be faster.

Use the built-in "default" procedures for inserts, e.g. TABLE_NAME.insert. For anything you need to execute frequently, as in thousands of times per second, try to use procedures. You can define procedures with either a java class or using the DDL-only "CREATE PROCEDURE ... AS " syntax. Remember to partition procedures if possible. But don't be afraid to use @AdHoc calls, especially for more dynamically-generated SQL statements.

Disclaimer: I work for VoltDB.