MySql: Will using Prepared statements to call a stored procedure be any faster with .NET/Connector?

后端 未结 1 1663
有刺的猬
有刺的猬 2021-01-15 06:02

I\'ve been reading a bit about Prepared statements with MySql, and the .NET/Connector does support them.

What I\'m wondering, is if I use a prepared statement to cal

相关标签:
1条回答
  • 2021-01-15 06:27

    A prepared statement requires a minimum of 2 db calls. The first call (prepare) takes your application level sql statement e.g. select * from users where user_id = ? and creates a query template in the database which is then parsed and validated. Subsequent calls simply involve passing values from your application layer to the db which are then inserted into the template and executed.

    A stored procedure already exists in the database. It has been parsed and validated during creation. A stored procedure is a bit like the template mentioned above but it's a permanent feature of the database not a temporary one.

    Therefore, to execute a stored procedure you only need to pass it params - you dont need to prepare it.

    0 讨论(0)
提交回复
热议问题