SQL inserts and stored procedures
Are there any performance gains in using stored procedures for simp开发者_JAVA百科le SQL inserts into tables over using direct SQL from java / JDBC? in my case I am using sybase but this could be a more general question.
Thanks
As long as you're using parameterized queries rather than building you queries via string concatenation, no (actually, you don't need the parameterized queries for performance either, just security).
A stored procedure won't give you performance gains on simple inserts.
On one hand it looks like there will be a performance improvement in going with SPs. Your insert statement is pre-compiled.
But, even if you are using SPs, you will be invoking the SPs via JDBC. Hence parsing that invocation, and binding the SP parameter-list will also require processing. If its 30-columns that you are trying to insert, thats still 30 parameters into the SP, that will need to be bound in the JDBC call.
Hence if its a simple SP thats doing an insert, I dont think Stored Procedures will buy you significant gains.
精彩评论