Adding `option(recompile)` to a select query
outamaa opened this issue · 3 comments
Some time ago I had an issue with cached execution plan resulting in order-of-magnitude slowdown of queries. One solution to this was to force SQL Server to recalculate the plan by adding option(recompile)
to the query. I managed to add it by extracting the query string using Deconstructor.select
, but this meant I had to stop using SelectAsyncOption
and instead reimplement the function in terms of the lower level QueryAsync
.
I was wondering if 1) there's an easier way to "just add this to the end of the query", and if not, 2) would you be open to adding something along the lines of justAddThisToTheEndOfTheQuery "option(recompile)"
as an escape hatch for these kinds of needs. If this is something you'd be willing to merge (with better naming of course), I can try and create a PR.
Hi @outamaa,
I think, in general, it would be possible to add it as a special optional parameter for select query (MSSQL only). Feel free to open PR and we can have a look.
FYI, putting this into v4
Now available in version 4