liveBook · Manning

Pull query

As explained in Kafka Streams in Action, Second Edition

A pull query retrieves point-in-time results from a materialized store instead of continuously receiving pushed results.

A pull query is a synchronous ksqlDB request that reads point-in-time results from a materialized store, returns them once, and then terminates. Unlike a push query, it does not keep streaming later changes to the client. section 11.1 section 11.3

Use a pull query when the caller needs an answer before continuing. It evaluates the current state rather than subscribing to updates; request it again to see newer results. Pull-query results are not shared, so identical requests from different clients execute separately. section 11.3 section 11.7

Choose among query styles by the result you need:

  • Use a persistent query for continual server-side processing whose results are stored in a Kafka topic and can be consumed by multiple clients. section 11.3
  • Use a push query for continual, client-directed updates without storing those returned results in a topic. section 11.3
  • Use a pull query for a single current-state result in a synchronous request-response workflow. section 11.3

Look up an activity leader

Query the activity_leaders materialized table by key to retrieve Smith’s current row: SELECT last_name, activity, total_steps FROM activity_leaders WHERE key_1 = 'Smith'. The query returns once rather than emitting subsequent changes. section 11.3

Pull queries support a limited subset of SQL. Their query form selects items from a materialized table with a WHERE clause, while persistent queries can use the full ksqlDB SQL syntax. section 11.3 section 11.7

Figure 11.3 Pull queries return point-in-time results once; to get updates, you need to resubmit the query.
figure

Compare a one-time pull result with a change subscription: updates require issuing the pull query again. section 11.3

How Kafka Streams in Action, Second Edition covers it

How deep it goes
Defines one-time execution, contrasts query modes, and shows a keyed WHERE lookup; defers specific SQL restrictions.
Examples
Demonstrates a key-based lookup of Smith in the activity_leaders table.
What it assumes
Introduces pull queries alongside basic ksqlDB query types and their stream or table targets.
What you can do after
Apply it via ksqlDB to retrieve a one-time current result and reissue requests for updates.
How it connects
Contrasts pull queries with persistent queries, push queries, materialized tables, Kafka topics, and streams.

Also explained in

Compare how 2 books explain pull 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.