> > That is a myth. Stored procedures are only faster than
> > dynamic queries; not prepared statements. In fact, in some
> > cases it is possible for a stored procedure to actually be
> > slower than a dynamic query.
>
> This is simply your opinion which differs greatly from the DBAs
> I've been involved with.

This isn't an opinion, but a simple fact. Stored procedures are not always
faster than ad-hoc queries. If, for example, you use a single stored
procedure which could return significantly different results depending on
inputs or the like, that procedure may reuse a compiled execution plan which
was best suited for the first set of results, but not best suited for the
next. To avoid this problem in SQL Server, you might specify the WITH
RECOMPILE option, which would give you the same results as using an ad-hoc
query.

As for prepared statements, they are typically as fast as stored procedures,
since they also take advantage of compiled execution plans. On some
platforms, they've actually appeared to be faster than using equivalent
stored procedures, although I can't explain why.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
phone: 202-797-5496
fax: 202-797-5444
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to