diff --git a/modules/learn/pages/services-and-indexes/services/query-service.adoc b/modules/learn/pages/services-and-indexes/services/query-service.adoc index 8c2be40750..f5f996e7a8 100644 --- a/modules/learn/pages/services-and-indexes/services/query-service.adoc +++ b/modules/learn/pages/services-and-indexes/services/query-service.adoc @@ -11,7 +11,8 @@ The Query Service depends on both the _Index Service_ and the _Data Service_. The architecture of the _Query Service_ is shown by the following illustration: [#query_service_architecture] -image::services-and-indexes/services/queryServiceArchitecture.png[,700,align=left] +.Query Service Architecture +image::services-and-indexes/services/queryServiceArchitecture.png[,700,align=centre] The principal components are: @@ -26,17 +27,27 @@ Other data stores are also included, such as the store for the local filesystem. == Query Execution -The sequence whereby queries are executed is shown below: +The following diagram shows the sequence of operations during query execution. [#query_sequence] -image::services-and-indexes/services/querySequence.png[,820,align=left] - -The client's {sqlpp} query is shown entering the Query Service at the left-hand side. -The Query Processor performs its *Parse* routine, to validate the submitted statement, then creates the execution *Plan*. -*Scan* operations are then performed on the relevant index, by accessing the *Index Service* or the *Search Service*. -Next, *Fetch* operations are performed by accessing the *Data Service*, and the data duly returned is used in *Join* operations. -The Query Service continues by performing additional processing, which includes *Filter*, *Aggregate*, and *Sort* operations. -Note the degree of parallelism with which operations are frequently performed, represented by the vertically aligned groups of right-pointing arrows. +.Query Execution Sequence +[plantuml,query-execution,svg] +.... +include::indexes:partial$diagrams/query-service.puml[] +.... + +When the Query Service receives the client's {sqlpp} query, it immediately passes it to the Query Processor. +The Query Processor first parses the query to validate the statement and then creates an execution plan for the request. + +The Execution Engine then begins executing the plan. +It performs Scan operations on the relevant index, using either the Index Service or the Search Service. +Next, it performs Fetch operations to get the actual data from the Data Service, and then uses this data for Join operations. + +The Query Service processes the data further by applying Filter, Aggregate, Project, and Sort operations. +These operations often run in parallel, as represented by the vertically aligned groups of right-pointing arrows. +Finally, it executes Offset and Limit operations to set the result size and starting point, and then streams the results back to the client. + +For more information about each of these operations, see xref:n1ql:n1ql-language-reference/selectintro.adoc#query-execution-phases[Query Phases]. == Using {sqlpp} diff --git a/preview/DOC-12349-query-execution-diagram.yml b/preview/DOC-12349-query-execution-diagram.yml new file mode 100644 index 0000000000..29e3f40fcd --- /dev/null +++ b/preview/DOC-12349-query-execution-diagram.yml @@ -0,0 +1,3 @@ +sources: + docs-devex: + branches: [DOC-12349-query-execution-diagram]