Raj N
Raj N

Reputation: 965

SQL inserts and stored procedures

Are there any performance gains in using stored procedures for simple 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

Upvotes: 0

Views: 136

Answers (2)

blispr
blispr

Reputation: 912

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.

Upvotes: 0

Justin Niessner
Justin Niessner

Reputation: 245419

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.

Upvotes: 3

Related Questions