What does parsing a query mean?
Asked Answered
P

3

9

Most relational databases handles a JDBC / SQL query in four steps:

  1. Parse the incoming SQL query
  2. Compile the SQL query
  3. Plan/optimize the data acquisition path
  4. Execute the optimized query / acquire and return data

I want to know what does "parse the incoming query" really mean? And what does "plan/optimize data acquisition path" mean?

Ponderable answered 22/8, 2014 at 19:48 Comment(0)
C
2
  1. Parsing means examining the characters input and recognizing it as a command or statement by looking through the characters for keywords and identifiers, ignoring comments, arranging quoted portions as string constants, and matching the overall structure to the language syntax making sense of it all.

  2. Plan/optimize means figure out the best way (of all the possible ways) to determine the result, usually with respect to execution time. It could also mean minimizing the number of locks needed. Maybe some parts of the query can be ignored (where ... and 1 == 1) or a table doesn't need to be accessed at all, etc.

Conclusive answered 22/8, 2014 at 19:50 Comment(0)
O
2

parsing is one of the Process of compilation.

Phases of a Compiler:

enter image description here

Source: Phases of Compiler

Oldie answered 22/8, 2014 at 19:55 Comment(0)
A
1

1) Parsing: syntactic analysis of the query according to the SQL grammar rules, etc. and attempting to "tokenize" the query into the elementary parts form.

2) Planning/optimization: at that stage the SQL engine tries to evaluate what the best way to execute your query would be. It tries to take advantage of existing indexes, clusters and table relationships; find ways around full table scans, utilize caching effectively by avoiding repeated data reads, and so forth.

Amaliaamalie answered 22/8, 2014 at 19:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.