# ForeignKey-Join and Materialization

**URL:** <https://forum.confluent.io/t/foreignkey-join-and-materialization/7256>\
**Category:** Kafka Streams\
**Created:** [17 February 2023 13:41 UTC](https://forum.confluent.io/t/foreignkey-join-and-materialization/7256 "2023-02-17T13:41:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomekkra](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/tomekkra/32/2639_2.png) [@tomekkra](https://forum.confluent.io/u/tomekkra)\
**Post date:** [17 February 2023 13:41 UTC](https://forum.confluent.io/t/foreignkey-join-and-materialization/7256/1 "2023-02-17T13:41:13Z")

</div>

Hi. I’m designing a solution where low latency and constant processing is an important requirement.

If we take a look at primary-key joins I can do sth like:

```auto
val tableA = builder.table(topic-1, Consumed.with(/**/), Materialized.with(/**/)

```

Then, If I set up `num.standby.replicas=1`, this table will be “replicated” to another node. And if a processing node dies, then a standby replica will be able to take over the task quickly since it has all the state for a given task present locally (replicated by a changelog topic).

However, I’m not sure how it exactly works with foreign key joins and whether materialization of the input table helps anyhow. I read the article on the confluent website about foreign-key joins, but it’s not easy to understand everything entirely since it’s quite complicated, and quite a few technical topics are created in the process.

To depict the join with the code:

```auto
val tableA = builder.table(topic-1, Consumed.with(/**/), Materialized.with(/**/)

tableB.join(tableA, foreignKeyExtractor, ValueJoiner, /*..*/)

```

Does this materialization of the tableA help anyhow with latency? Can I take any measures to allow kafka-streams take-over the task if an instance leaves the consumer group?

Thanks!

---

<div class="post-metadata">

**Author:** ![bbejeck](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/bbejeck/32/412_2.png) [@bbejeck](https://forum.confluent.io/u/bbejeck)\
**Post date:** [17 February 2023 15:47 UTC](https://forum.confluent.io/t/foreignkey-join-and-materialization/7256/2 "2023-02-17T15:47:28Z")

</div>

Hi @tomekkra,

Materialization occurs for the `KTable` even if you don’t include it as a parameter in the overloaded `StreamBuilder.table` method. The difference between including a `Materialized` or not is exposure for Interactive Queries - not supplying it means it’s not available for querying.  
The best thing you can do for availability is to leverage standby tasks by setting `num.standby.replicas`\> 1, which you’re already doing.

HTH,  
Bill
