title: Clearing prepared statement cache in cassandra 3.0.10
body: <p>We have cassandra 3.0.10 installed on centos. The developers made some coding mistakes on preparing statements. The result is that the prepared statement cache is overrunning and we always get evicted error message. The error is shown below:</p>
  
  <pre><code>INFO [ScheduledTasks:1] 2017-12-07 10:38:28,216 QueryProcessor.java:134 - 7 prepared statements discarded in the last minute because cache limit reached (8178944 bytes) 
  </code></pre>
  
  <p>We have corrected the prepared statements and would like to flush the prepared statement cache to start from scratch. We have stopped and restarted the cassandra instance but the prepared statement count was not reset.</p>
  
  <p>Cassandra 3.0.10 is installed on centos and we are using svcadm disable/enable cassandra to stop/start cassandra.</p>
  
  <p>I noticed that in later version of cassandra, e.g. 3.11.1, there is a prepared_statements table under the system keyspace. Shutting down cassandra and deleting the file <code>${CASSANDRA_HOME}/data/data/system/prepared_statements-*</code>, then restart cassandra actually resets the prepared_statement cache.</p>
  
  <p>Appreciate any help on this.</p>
  
  <p>Thanks.</p>
  
  <p><strong>Update: 2018-06-01</strong>
  We are currently using a work-around to clear prepared statements associated with certain tables by dropping index then recreating the index on the table. This discards prepared statements that have dependencies on the defined index. For now, this is the most we can do. Problem is, if this won't work for tables that don't have index defined on them.</p>
  
  <p>Still need a better way of doing this, e.g. some admin command to clear the cache.</p>