I thought about how can it work under the hood and I came with an idea

  • Db engine receives query with parameters and also defined values of those parameters

  • SQL is being parsed into syntax tree like that

enter image description here

  • After parsing values of parameters are inserted into tree to places where associated with them parameters are

  • Query is being executed without another parsing

Is it at least conceptually true?

  • That depends on the actual database engine beeing used, however I would agree that an efficient engine would not do string replacement and parse the query again (but I am also sure there are engines which are not so sophisticated). For Oracle there is a soft/hard parse destination and parameter binding is one of the phases after that.
    – eckes
    Feb 13, 2019 at 11:20


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.