简体   繁体   中英

Cassandra Prepared Statement in CQL3 using thrift

I'm looking for information about prepared statements(ps) livecycle.

I'm using BasePoolableObjectFactory provided by apache to make connection pool. Then, using TSocket and TTransport, I'm making an object from Cassadra.Client class. This object has methods to execute cql3 queries. Also the object has method to prepare and execute cql3 query, ie we can make prepared statements using thrift.

Where are prepared statements stored? In database server or they exist as long as the object exist?

If they are stored in database server, how can I get then, without creating them again? If they are stored in object, what is prepared then, when each time query is submitted to the server?

I'm asking, cos I want to know when it is worth making prepared statements. Because if I make a prepared statement, execute it once and close the connection, then there is no need to make prepared statements at all.

Prepared statements are cached per-connection. (You access them with the id that the server gives you back as the result of the prepare call.)

So no, there is no point in using them for one-shot queries. This is common across any prepared statement design.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM