Home / Companies / ScyllaDB / Blog / Post Details
Content Deep Dive

Stop Wasting ScyllaDB’s CPU Time by Not Being Prepared

Blog post from ScyllaDB

Post Details
Company
Date Published
Author
Shlomi Livne
Word Count
772
Language
English
Hacker News Points
-
Summary

Prepared statements in ScyllaDB optimize query execution by parsing a CQL statement once and caching the result, which enhances performance and security by reducing the computational load and protecting against SQL injection. The process involves hashing a CQL statement to check against ScyllaDB's query cache, and if absent, parsing and storing it for future reference. Performance tests demonstrate significant improvements when using prepared statements, with notable increases in operation and partition rates and reduced latency compared to non-prepared statements. Prepared statements also allow the client to direct queries to the correct data node, minimizing data transfer hops. Monitoring tools and metrics, such as scylla_query_processor_statements_prepared, can help assess the effectiveness of prepared statements, and Wireshark supports the analysis of ScyllaDB's prepared statement packets. The article emphasizes the importance of using prepared statements for repeated query executions to leverage future performance enhancements.