×

Query processing in DBMS

Operations on DBMSs are made much simpler, more organized, and methodical with SQL.

These are not only simpler for people to comprehend, but after gaining a basic comprehension of them, they often start to seem more intuitive. SQL has undergone significant development as a DBMS. It even determines the most effective technique to perform our queries for us.

In a distributed database management system, query processing necessitates data transit across networked computers.

The sequence of data transfers and local data processing is a distribution strategy for a query in a database system.

In a distributed DBMS, a query frequently requires data from various places. The need for data from many sources is defined as the transmission of data that increases communication expenses.

Due to the communication costs of data transfer over the network, query processing in DBMS differs from query processing in centralized DBMS. The cost of transmission is very low when sites are connected by high-speed networks, but it may be very expensive in other networks.

The process of extracting data from a database is called query processing.

It requires several steps to retrieve the data from the database during query processing. The involved actions are:

  • Translation and parsing
  • Optimization
  • Evaluation

The following describes how the query processing operates:

Translation and parsing:

Because certain operations for data retrieval are included in query processing. First, high-level database languages like SQL are used to translate the user queries that have been provided.

It is transformed into phrases that can be applied further at the file system's physical level. Following this, the queries are evaluated together with several query-optimizing changes.

Consequently, a computer system must convert a query into a language that is legible and intelligible by humans before processing it. Therefore, the greatest option for humans is SQL or Structured Query Language. However, it is not entirely appropriate for the internal representation of the system's question. Relational algebra works best with the internal representation of a query.

In query processing, the translation process is comparable to the query parser.

The system parser examines the query syntax, the name of the database relation, the tuple, and eventually the needed attribute value to construct the query's internal form when a user executes a query.

The query is represented as a tree by the "parse-tree" that the parser creates. Convert it to relational algebraic form after that. This eliminates any instances of the query successfully utilizing views.

Query processing in DBMS

Let's say a user runs a query.

There are numerous ways to extract data from a database, as we have learned. A user in SQL wishes to retrieve the employee records whose salaries are greater than or equal to 10000. To accomplish this, the following investigation is made

select emp_name from Employee where salary>10000;

Query evaluation:

The next stage is to apply specific rules and algorithms to build a few other potent and effective data structures once the query processor has the relational forms at its disposal.

These data structures aid in creating the plans for query evaluation. For instance, there can be several routes from source to destination if the relational graph was built. For each of the pathways, an execution plan for the query will be created.

Query evaluation plan:

  • To fully examine a question, the system must develop a query evaluation plan.
  • The algorithms to be utilized for the specific index or the individual operations may be mentioned in the annotations in the assessment plan.
  • Evaluation Primitives are a type of relational algebra with annotations. The instructions required for evaluating the operation are carried out by the evaluation primitives.
  • As a result, a query evaluation plan specifies the order in which primitive operations are performed to evaluate a query. The phrase "query execution plan" can also be used to refer to the query assessment plan.
  • A query execution engine produces the outcome of the specified query. After executing the query execution plan, it creates the output for the user query.

Query optimization:

The most effective evaluation strategy is chosen by DMBS in the following stage based on the costs associated with each plan. Here, it's important to reduce the time spent on query evaluation.

The optimizer also assesses how well the table's index and currently utilized columns are being utilized. To guarantee that only the best plans are carried out, it also determines the optimal sequence in which subqueries should be conducted.

Simply said, various evaluation strategies can be used to run any query. Choosing the option with the lowest cost is referred to as query optimization. The optimizer considers several parameters when determining how much a query evaluation plan will cost, including:

  1. CPU use
  2. Number of tuples to be scanned
  3. Storage access time
  4. Number of operations

Conclusion

The system evaluates the generated low-level query once the query evaluation plan has been chosen before delivering the results.

Although the query goes through several steps before being completed, these steps are quite quick compared to the time it would take to execute an unvalidated and unoptimized query.

Learn more about indexes and evaluate the performance of your queries if you don't add the proper indexes. In short, there are two steps involved in a query's processing flow:

Compile time

  • Parsing and translation: separate the query into tokens and ensure that the query is correct.
  • Query optimization involves comparing various query execution plans to determine which one is the best.
  • Create low-level, database executable code for queries.
  • Running time

Related Topics

Types of Data Abstraction in DBMS

What Is Data Abstraction? To ship an email, you want to know the address. But to send the email, you don't need to see where the email is physically stored. You...

6 minutes read.

Domain in DBMS

Constraints: Constraints in DBMS are a set of guidelines that guarantee that authorized users who modify the database do not alter the consistency of the data. Constraints are expressed in DDL...

3 minutes read.

Advantages of Threaded Binary Tree in DBMS

We know that every node in a binary tree contains both its data value and the address pointers for its left and right children. A null pointer is used to...

3 minutes read.

BCNF in DBMS

BCNF stands for Boyce–Codd Normal Form. What is the Normal form? The normal form is mainly used to reduce the redundancy of the database tables. Or we can say that the normal form...

4 minutes read.

3- Tier Architecture in DBMS

Three-tier architecture is an application software architecture that arranges the output into three parts or tiers that are:  the presentation tier, where the user interacts with the application; the application...

4 minutes read.

Checkpoint in DBMS

A checkpoint in DBMS is used to define a point of the transaction that is in a consistent state and then all the transactions will be in the committed state...

4 minutes read.

Secondary Key in DBMS

What are Keys? Keys in DBMS are the attributes or set of attributes that uniquely identify a row in a set of relations. A table (relation) can have a column or...

3 minutes read.

B Tree in DBMS

How to perform Insertion operation in B Tree A new value is inserted at the leaf node. Same like in a binary search tree we traverse from starting root node to...

10 minutes read.

Conversion of ER Diagram into Relational Model

After designing the Entity-Relationship diagram, you need to convert it into tables in the relational model. Because the relational model can be easily implemented by the Relational DBMS like Oracle, MySQL, etc....

2 minutes read.

Data Models in DBMS

Data Models in DBMS Data models are the models explaining the logical structure of the database systems. They describe the entities, attributes, and the relationship among the data elements of the...

8 minutes read.

Redundancy in DBMS

Data redundancy is a situation that is created in the database in which the same amount of data is stored in two different places. The different places are found in a...

3 minutes read.

Primary Key in DBMS

Primary Key in DBMS: A primary key is the minimal set of columns in the database table, which uniquely identifies each row or tuple in that table. Any table in...

2 minutes read.

Schedule in DBMS

Schedule A sequence of statements that specify the sequential order in which the statements of concurrent transactions are executed. The transaction will get committed when it executes the instructions successfully without any...

4 minutes read.

Characteristics of DBMS

Introduction to DBMS: A database management system (DBMS) is a software application that is designed to manage and organize data stored in a database. It is responsible for storing, retrieving, and...

3 minutes read.

Difference between Dropbox and Amazon Drive

What is Dropbox? It is a file organising company that is owned by the American Company Dropbox Inc. Itsheadquarters is situated in San Francisco, California, U.S. Dropbox offers personal cloud, client...

3 minutes read.

What is RDBMS?

To discuss the Relational Database Management System, there are some terms and concepts you need to know. Database Any collection of related information is called a database. The phone book is...

5 minutes read.

Defference between Database and Data Warehouse

Database A database is a collection of related information is called a database. It has some elements that can be mapped to real-world objects. It is designed in such a manner...

4 minutes read.

Red-Black Tree Visualization in DBMS

Introduction to Red Black Tree A red-black tree is a self-balanced binary search tree with an extra bit per node, usually read as a color (red or black). The tree is...

4 minutes read.

Constraints in Database Management System

In a database management system, certain constraints are applied while performing any operation on the database to ensure that the integrity and quality of the data are maintained throughout the...

4 minutes read.

DBMS Architecture

Architecture of Database Management System DBMS architecture helps in development, implementation, design, and maintenance of a database that store and organize information for agencies, businesses, and institutions. It is the base of any database...

2 minutes read.