---
title: "Why We Ditched Flink Table API Joins: Cutting State by 75% with DataStream Unions"
description: "Chained Flink 1.20 Table API/SQL joins amplified state because each join operator keeps its own copy of upstream records in RocksDB, pushing Zalando's Product Offer Enrichment jobs to about 240GB of state."
url: "https://swe.quest/articles/why-we-ditched-flink-table-api-joins-cutting-state-by-75-with-datastream-unions-939c1fa5429761f5"
canonical: "https://engineering.zalando.com/posts/2026/03/why-we-ditched-flink-table-api-joins-cutting-state.html"
source: "Zalando Engineering"
published: "2026-03-03"
difficulty: "hard"
kind: "Case study"
reading_minutes: 9
tags: ["stream-processing","performance","cost-optimization","cloud"]
---

# Why We Ditched Flink Table API Joins: Cutting State by 75% with DataStream Unions

A post on [Zalando Engineering](https://swe.quest/sources/zalando.md), published 2026-03-03, 9 min read, Case study. Original: [https://engineering.zalando.com/posts/2026/03/why-we-ditched-flink-table-api-joins-cutting-state.html](https://engineering.zalando.com/posts/2026/03/why-we-ditched-flink-table-api-joins-cutting-state.html)

## Summary

Chained Flink 1.20 Table API/SQL joins amplified state because each join operator keeps its own copy of upstream records in RocksDB, pushing Zalando's Product Offer Enrichment jobs to about 240GB of state. Hourly savepoints then pinned CPU at 100%, caused backpressure, crash-restart loops and failed snapshots, and forced 10–20% overprovisioning on AWS Managed Flink. Replacing the join chain with a union of all streams into one DataStream, processed by a single keyed process function holding one ValueState per SKU with timestamp-based filtering and deduplication, cut state to 56GB and snapshot time from 11 to 2.5 minutes. AWS cost fell only 13%, because KPU billing tracks CPU and memory rather than state size. The same idea ships in Flink 2.1 as the experimental Multi-Way Join operator.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Stream processing](https://swe.quest/tags/stream-processing.md) (Data & databases)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Cost optimization](https://swe.quest/tags/cost-optimization.md) (Reliability & operations)
- [Cloud platforms](https://swe.quest/tags/cloud.md) (Infrastructure)

## Prerequisites

- Apache Flink basics ([easy posts on Stream processing](https://swe.quest/tags/stream-processing.md?difficulty=easy))
- stateful stream processing ([easy posts on Stream processing](https://swe.quest/tags/stream-processing.md?difficulty=easy))
- RocksDB state backend
- Flink checkpoints and savepoints ([easy posts on Stream processing](https://swe.quest/tags/stream-processing.md?difficulty=easy))

## Keywords

Apache Flink, Flink Table API, Flink DataStream API, RocksDB, AWS Managed Service for Apache Flink, KeyedProcessFunction, Scala, Multi-Way Join Operator

## Related posts

- [From Homegrown to Flink: Migrating a Stateful Ad Event Join at Scale](https://swe.quest/articles/from-homegrown-to-flink-migrating-a-stateful-ad-event-join-at-scale-34697efa4030f6e1.md): Zalando Engineering · 2026-07-23 · Hard · 12 min read · Stream processing, Storage engines, Performance engineering, Kubernetes, Ads
  Zalando's Ad Platform team replaced a 7-year-old homegrown Java service that joins ad auction (bid) events with user interaction events within a 15-minute window with an Apache Flink pipeline using RocksDB state and incremental checkpoints.
- [7 Tips For Optimizing Apache Flink Applications](https://swe.quest/articles/7-tips-for-optimizing-apache-flink-applications-be2dbc2fd7e74cd5.md): Shopify Engineering · 2022-03-08 · Medium · 14 min read · Stream processing, Performance engineering, Java & JVM, Debugging
  Lessons from running large stateful Apache Flink jobs (up to 13 TB of state) on GKE with the RocksDB state backend and checkpoints on GCS.
- [Reducing BigQuery Costs: How We Fixed A $1 Million Query](https://swe.quest/articles/reducing-bigquery-costs-how-we-fixed-a-1-million-query-623d7a6f57bc4fa3.md): Shopify Engineering · 2022-11-03 · Medium · 5 min read · Analytics & OLAP, Cost optimization, Cloud platforms, Stream processing
  Clustering a BigQuery table on two columns used in a query's WHERE clause cut the data scanned per query from about 75 GB to roughly 100–500 MB, turning a projected ~$949K/month bill into about $1,370/month.
- [Scaling SaaS security: Reco’s migration from Postgres to ClickHouse Cloud](https://swe.quest/articles/scaling-saas-security-reco-s-migration-from-postgres-to-clickhouse-cloud-644c039f853be147.md): ClickHouse · 2025-11-17 · Medium · 6 min read · Analytics & OLAP, PostgreSQL, Stream processing, Performance engineering, Cost optimization
  Reco, a SaaS security platform ingesting 10-12 billion JSON events weekly, moved over 90% of its workload from Postgres to ClickHouse Cloud.
- [Goldsky - A Gold Standard Architecture with ClickHouse and Redpanda](https://swe.quest/articles/goldsky-a-gold-standard-architecture-with-clickhouse-and-redpanda-347e225c0fe7c7a7.md): ClickHouse · 2023-12-20 · Medium · 9 min read · Analytics & OLAP, Stream processing, Queues & messaging, Multi-tenancy, Data pipelines
  Goldsky streams blockchain data to potentially thousands of customer ClickHouse clusters by indexing chains into per-data-type Redpanda topics (Avro, infinite retention via tiered storage), applying per-customer FlinkSQL filters, joins and aggregations in stream at up to 500k events/sec, and delivering results to ClickHouse.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
