liveBook · Manning

Pull query

As explained in Kafka for Architects

A pull query is an on-demand query that retrieves the current state of data and terminates after returning its result.

A pull query answers a one-time state question: it runs on demand, retrieves current data, returns the result, and terminates. Unlike a push query, it does not continuously process an unbounded stream or emit later updates. section 8.4.1

Choose the lookup path according to where the current state resides:

  • Querying a stream or table scans the underlying Kafka topic, changelog, or original stream for the most recent matching record. section 8.4.1
  • Querying a materialized view reads a continuously updated, locally stored view backed by RocksDB and replicated through Kafka, avoiding a topic scan. section 8.4.1

Current order state

A request such as “What is the status of order 123?” needs the state at query time, not a continuously running application. A high-value-order filter can be expressed as SELECT * FROM Orders WHERE paid_amount > 100. section 8.4.1

Listing 8.2 Selecting high value orders
SELECT * FROM Orders
WHERE paid_amount > 100;

Shows a concise filtering query over an Orders relation. section 8.4.1

How Kafka for Architects covers it

How deep it goes
Explains transient execution and contrasts topic scanning with materialized-view lookup.
Examples
Uses an order-status question and a filtered high-value-orders query.
What you can do after
Apply it via ksqlDB to retrieve current results without deploying a continuously running application.
How it connects
Connects pull queries to push queries, streams, tables, materialized views, RocksDB, and Kafka topics.

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 for Architects. The section links point to the parts of the book it draws on.