> For the complete documentation index, see [llms.txt](https://vikram-bajaj.gitbook.io/cs-gy-6083-principles-of-database-systems/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vikram-bajaj.gitbook.io/cs-gy-6083-principles-of-database-systems/dbms-internals/query-processor.md).

# Query Processor

It is responsible for parsing, translating, optimizing and evaluating queries.

![](https://1736932896-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M5-0RGXrGEYT2sPemdS%2F-M5-0Rgnjb23s9oFr3lT%2F-M5-0_5FhvvEqMr82srv%2FQuery%20Processor.JPG?generation=1586990834246133\&alt=media)

There are 2 alternative ways to evaluate a query:

* using equivalent expressions
* using different algorithms for each operation

We must choose the method that has the least cost.

There are two approaches to select the best query evaluation plan:

* **cost-based**: considers the cost of the operations; however, it needs statistical information about data in the database
* **rule-based**: uses a set of rules to determine how to execute a query
