question

praveenkg avatar image
praveenkg asked Erick Ramirez answered

Is there any performance implication with SimpleStatement vs PreparedStatement?

We are developing an application where we either inserting/updating over 300 tps. During the insert/update some of the columns will be null. We thought to use prepared statement for both insert/update for better performance. However with null values for some data as few columns, I am thinking to use Simple Statement by creating a dynamic query for not null columns. Could you pls let me know is there any performance implication with SimpleStatment for insert/update ?

prepared statement
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered

If performance matters and queries are repeatedly used by your application then using prepared statements is the way to go.

You shouldn't include a null column in any INSERT or UPDATE or a tombstone gets generated in the database. You can create multiple prepared statements depending on the query that needs to be executed so you don't include columns with have null values.

Note that not all variables in the prepared statement need to be bound. You can use the unset() method so tombstones are not generated in the database.

For details, see Prepared statements with the Java driver. For other languages, see the equivalent driver pages. Cheers!

Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.