开发者

Stored procedures vs. parameter binding

I am using SQL server and ODBC in visual c++ for writing to the database. Currently i am using parameter binding in SQL queries ( as i fill the 开发者_如何学Godatabase with only 5 - 6 queries and same is true for retrieving data). I dont know much about stored procedures and I am wondering how much if any performance increase stored procedures have over parameter binding as in parameter binding we prepare the query only once and just execute it later in the program for diferent set of values of variables.


Stored procedures should be more performant for a few reasons:

  • Less network traffic - the query is on the DB and you just send a small command to the DB with params vs sending the entire query every time
  • The query is pre compiled on the server and can be cached as well by the DB

Another advantage is that you can alter the query on the DB without having to recompile the code. This is an additional layer of abstraction that I find very useful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜