


I'm familiar with the RECOMPILE option to flag a procedure to always recompile.
#Recompile a stored procedure manual
Not to mention that when we're relying on manual recompiles, a query that runs quickly on our Staging environment might take 20s to run on our Production environment just because of the luck of the draw with the execution plan used in the compiled sproc. We can fix this by recompiling the procedure (after which even the 50,000 row version executes very quickly), but we can't be expected to manually monitor every single one of these queries and recompile the problem ones when they start acting slow. Additionally, if the stored procedure has to be recompiled at only one time, in that case, you can add RECOMPILE word one time only and run the SP as well. With the way SQL Server optimizes these types of queries, the "small" queries might run in 100ms, while the same exact procedure returning "large" amounts of data might take on the order of 10 seconds. When a stored procedure is created (I suspect you are calling ad-hoc sql from. place so SQL Server will have to recompile the stored procedure during execution. If you want your stored procedure to always recompile at run time, you can add the keyword RECOMPILE when you create the stored procedure.

However, the issue we've been running into is that the same procedure can be used to pull both "small" amounts of rows (say 10-15) and "large" amounts of rows (say 50,000). So my stored procedures look a lot like: AS IdListTableType ids INNER JOIN Customers c ON ids.Id = c.CustomerId I have a bunch of procedures that accept as an input a User Defined Table Type that is basically just a table with a single column, containing all of the ids I want to pull from a table. We are using SQL Server 2014, by the way, I believe.
#Recompile a stored procedure full
NET application that is based on the concept of fetching "ids" (usually integer values), then passing those ids to the database, where the database will join against those ids and an actual db table to return the full row from the db for each id. I've been building a data access layer in a. I would appreciate any help with a certain type of query. I've got a question related to what I think comes down to Execution Plans and Parameter Sniffing for stored procedures.
