0
710views
Explain the steps in query processing.

Explain the steps in query processing.

1 Answer
0
12views


Steps in Query Processing :-

1. Formulation of continuous queries :-

  • The formulation of queries is mostly done using declarative languages like SQL in DBMS. Since there are no standardized query languages to express continuous queries, there are a lot of languages and variations.

  • However, most of them are based on SQL, such as the Continuous Query Language (CQL) and StreamSQL.

  • The language strongly depends on the processing model.

  • In StreamSQL, a query with a sliding window for the last 10 elements looks like follows: SELECT AVG (price) FROM examplestream [SIZE 10 ADVANCE 1 TUPLES] WHERE value > 100.0 This stream continuously calculates the average value of price of the last 10 tuples, but only considers those tuples whose prices are greater than 100.0.


2. Translation of declarative query :-

  • In this step, the declarative query is translated into a logical query plan.

  • A query plan is a directed graph where the nodes are operators and the edges describe the processing flow.

  • Each operator in the query plan encapsulates the semantic of a specific operation, such as filtering or aggregation.

  • DSMSs process relational data streams and the operators are equal or similar to the operators of the Relational algebra.

  • Operator for selection, join, projection and set operations allows very flexible and versatile processing of a DSMS.


3. Optimization of queries :-

  • The logical query plan can be optimized, which strongly depends on the streaming model.

  • The basic concepts for optimizing continuous queries are equal to those from database systems. If there are relational data streams and the logical query plan is based on relational operators from the Relational algebra, a query optimizer can use the algebraic equivalences to optimize the plan.


4. Transformation of queries :-

  • Since a logical operator is only responsible for the semantics of an operation but does not consist of any algorithms, the logical query plan must be transformed into an executable counterpart. This is called a physical query plan.

  • The distinction between a logical and a physical operator plan allows more than one implementation for the same logical operator. For example, join is logically the same, although it can be implemented by different algorithms like a nested loop join or a sort-merge join.

  • These algorithms also strongly depend on the used stream and processing model. Finally, the query is available as a physical query plan.


5. Execution of queries :-

  • Physical query plan can be directly executed because it consists of executable algorithms. For this, the physical query plan is installed into the system.

  • The bottom of the graph (of the query plan) is connected to the incoming sources, which can be everything like connectors to sensors.

  • Since most DSMSs are data-driven, a query is executed by pushing the incoming data elements from the source through the query plan.

Please log in to add an answer.