title: Difference between KTable and local store
body: <p>What the difference between these entities?</p>
  
  <p>As i think, KTable - simple kafka topic with <code>compaction</code> deletion policy. Also, if logging is enabled for KTable, then there is also changelog and then, deletion policy is <code>compaction,delete</code>.</p>
  
  <p>Local store - In-memory key-value cache based on RockDB. But local store also has a changelog.</p>
  
  <p>In both cases, we get the last value for key for a certain period of time (?). Local store is used for aggregation steps, joins and etc. But new topic with compaction strategy also created after it. </p>
  
  <p>For example:</p>
  
  <pre><code>KStream&lt;K, V&gt; source = builder.stream(topic1);
  KTable&lt;K, V&gt; table = builder.table(topic2); // what will happen here if i read data from topic with deletion policy delete and compaction? Will additional topic be created for store data or just a local store (cache) be used for it?
  
  // or
  KTable&lt;K, V&gt; table2 = builder.table(..., Materialized.as("key-value-store-name")) // what will happen here? As i think, i just specified a concrete name for local store and now i can query it as a regular key-value store
  
  source.groupByKey().aggregate(initialValue, aggregationLogic, Materialized.as(...)) // Will new aggregation topic be created here with compaction deletion policy? Or only local store will be used?
  </code></pre>
  
  <p>Also i can create a state store using builder <code>builder.addStateStore(...)</code> where i can enable/disable logging(changelog) and caching(???).</p>
  
  <p>I've read this: <a href="https://docs.confluent.io/current/streams/developer-guide/memory-mgmt.html" rel="noreferrer">https://docs.confluent.io/current/streams/developer-guide/memory-mgmt.html</a>, but some details are still unclear for me. Especially the case when we can disable StreamCache (but not RockDB cache) and we will get a full copy of CDC system for relational database</p>