开发者

Does naming function in MSSQL like fn_myFuction take additional performace

开发者 https://www.devze.com 2023-01-25 00:04 出处:网络
Someone here mentioned that We should avoid naming stored procedures in MS SQL server like sp_XXX Because that taking addition time to SQL server while check does exist system sotred procedure named l

Someone here mentioned that We should avoid naming stored procedures in MS SQL server like sp_XXX

Because that taking addition time to SQL server while check does exist system sotred procedure named like that. Because all system stored procs are starting with sp_.

Now I wondering is that a case with Functions in MSSQL, Does naming functions like fn_ take additional开发者_如何学运维 time to SQL while looking for system functions ?


No, I don't think so.

Found the following thread:

http://bytes.com/topic/sql-server/answers/78872-udf-starting-fn_

No. To call a system-supplied [User Defined Function], you need to use ::, so that is what SQL Server looks for. All system-supplied UDFs are table functions, as scalar system functions are not UDFs at all.

Hope this helps


For functions it does not matter, however it is recommended to NOT use a prefix of sp_ for stored procedures as it defines a system stored procedure and may cause an extra lookup in the MASTER database.

As sp_ prefix is reserved for system stored procedure and any stored procedure which has sp_ prefix will cause an extra lookup in MASTER database. There is another point to note that if a stored procedure uses same name, in user database as system stored procedure in master database, the stored procedure in user database will never get executed as SQL Server will always look first in master database and will execute that one rather one in user database.

http://furrukhbaig.wordpress.com/2007/08/22/stored-procedures-factssheet/

http://msdn.microsoft.com/en-us/library/dd172115.aspx

0

精彩评论

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