liveBook · Manning

Continuous query

As explained in Kafka Streams in Action, Second Edition

A push query is a continuous ksqlDB query that emits changing results to the client that issued it without persisting those results in a topic.

A continuous query in ksqlDB is a push query: it keeps evaluating incoming records and streams changing results to the client that issued it. Because an event stream does not stop, the query runs until it is explicitly terminated or the client connection ends. Its results are returned directly rather than stored in a Kafka topic. section 11.1 section 11.7

Use a push query when a client needs ongoing asynchronous updates, optionally narrowed to selected columns or filtered rows. This differs from a persistent query, which runs on the server and writes reusable results to a Kafka topic, and a pull query, which returns a point-in-time result once and then ends. section 11.3 section 11.7

A push query has these working properties:

  • Runs continually against new records from a stream or table until termination. section 11.3
  • Sends results only to the originating client; it does not persist them in a topic for other consumers. section 11.3
  • Uses SELECT … FROM … EMIT CHANGES syntax and can add WHERE filtering or LIMIT. section 11.3
  • Can query base streams or tables as well as results produced by persistent queries. section 11.4

Stream activity-leader updates

Select last name, activity, and total steps from an activity_leaders table with EMIT CHANGES to receive each update as it arrives. Add WHERE total_steps > 1000 to stream only qualifying updates, or LIMIT 10 to stop after ten returned rows. section 11.3

Figure 11.2 Push queries don’t store results but return them to the client that submitted the query.
figure

Use this diagram to distinguish direct client delivery from persistent-query results written to a Kafka topic. section 11.3

How Kafka Streams in Action, Second Edition covers it

How deep it goes
Defines execution and delivery behavior, then demonstrates SELECT, WHERE, and LIMIT without detailing query internals.
Examples
Uses activity_leaders selections with EMIT CHANGES, a total_steps filter, and a ten-row limit.
What it assumes
Introduces continuous execution while deferring unfamiliar pull-query details until later.
What you can do after
Apply it via ksqlDB to receive filtered, continually changing stream or table results in a client.
How it connects
Contrasts push queries with persistent queries, pull queries, Kafka topics, streams, and tables.

Also explained in

Compare how 2 books explain continuous query →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kafka Streams in Action, Second Edition. The section links point to the parts of the book it draws on.