Kim Stuart
Kim Stuart

Reputation: 9

Are NoSQL User Defined Functions (UDFs) and Triggers executed at the application level or the DB level?

I am trying to understand the internals of NoSQL, specifically Apache Cassandra, and I have an object execution question.

I understand that natively, NoSQL does not support stored procedures, but user defined functions (UDFs) and triggers are supported, but must be implemented through a client driver in which these objects are created in a JVM that is essentially stored in a Cassandra lib/triggers type of directory and loaded into the db clusters during cluster startup.

Per the Apache Cassandra documentation, they state the following:

The actual logic that makes up the trigger can be written in any Java (JVM) language and exists outside the database. You place the trigger code in a lib/triggers subdirectory of the Cassandra installation directory, it loads during cluster startup, and exists on every node that participates in a cluster.

Is the actual execution of these objects performed server/application side and then results passed into Cassandra, or does Cassandra have the capability to interpret these objects and execute them on the db side?

The reason I ask is because my goal is to reduce server side calls and let the server/application run as freely as possible and put more of the data manipulation duties on the database. In a sense, a pump and dump type of flow, where the server sends data to the db, forgets it and moves on back to the application to listen for more requests without needing additional time to process data.

Upvotes: 0

Views: 56

Answers (1)

Aaron
Aaron

Reputation: 57798

natively, NoSQL does not support stored procedures

In general, I would say this is likely correct. However, there are many NoSQL databases and they vary significantly by feature set.

is the actual execution of these objects performed server/application side and then results passed into Cassandra, or does Cassandra have the capability to interpret these objects and execute them on the db side?

In Cassandra, UDFs and triggers are 100% executed on the database side. That's why it's important for a custom trigger's JAR to be in the lib/ directory on all nodes in the cluster. Likewise, a UDF is a part of the schema, and relies on all nodes being on the same schema version.

Upvotes: 0

Related Questions