liveBook · Manning

Single-service query

As explained in Microservices Patterns, Second Edition

A query whose required data is contained within a single service rather than spanning multiple services.

A single-service query reads data held by one service, but that service’s database may not efficiently support the query’s workload. The problem is not necessarily crossing service boundaries: a query can be difficult because it combines demanding search types, requires denormalized data, or must scale. section 13.1 section 13.1.2

Assess the operational trade-offs before optimizing the query:

  • Additional indexes can improve query performance but add write overhead because inserts, updates, and deletes must maintain them. section 13.1.2
  • Queries requiring many expensive joins can increase latency and database load; a denormalized, pre-joined schema can serve them in a query-optimized form. section 13.1.2
  • A query needing relational, text, and geo search may be difficult to support alongside relational management operations in one database. section 13.1.2

Restaurant availability search

findAvailableRestaurants() filters for restaurants open at a requested delivery time, searches near the delivery address, and matches keywords against restaurant names, descriptions, and menu items. The high-volume hybrid query shares a service with lower-volume relational restaurant management. section 13.1.2

Figure 13.2 The Restaurant Service has two very different sets of requirements, which would be challenging to satisfy with a single database: low-volume restaurant management operations that maintain relational restaurant information, such as opening hours and menus, and a high-volume findAvailableRestaurants() query that is a blend of relational, text, and geo search.
SingleServiceQueryChallenges

Contrasts restaurant management operations with the high-volume hybrid search they must coexist with. section 13.1.2

How Microservices Patterns, Second Edition covers it

How deep it goes
Explains index write overhead, join costs, and hybrid search challenges, but does not specify a complete implementation.
Examples
Uses restaurant availability search combining opening-time filters, location search, and keyword matching.
What you can do after
Evaluate query and write-performance trade-offs, including index overhead, join costs, and mixed search requirements.
How it connects
Connects single-service queries with API Composition, CQRS, relational databases, and non-relational search.

Related concepts

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