# Query Processor

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

![](/files/-M5-0_5FhvvEqMr82srv)

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://vikram-bajaj.gitbook.io/cs-gy-6083-principles-of-database-systems/main-1/dbms-internals/query-processor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
