Using plan guides

PhennoPhenno Member Posts: 630
Hi all!

Could I have a problem if I use sp_create_plan_guide to create a fixed plan guide for a specific query in NAV2013+?

I have a situation where there is a table with Entry No. as CI and Table No., Entry No. as NCI. I need to filter that table by Table No. and find first Entry No. occurring after specific entry no. so my query looks like:
Select TOP (1) timestamp, "Entry no.", "Table no.", "other fields" from MyTable where "Entry No." > @0 and "Table No." = @1 (OPTIMIZE FOR UNKNOWN)

Since this is parametrized query and table is large I receive a really bad execution plan with clustered index seek. Higher my entry no. in filter is the larger number of reads I get.

I've tested with sp_create_plan_guide and RECOMPILE option for this query and I get only few reads per query, but not sure if that will led to other problems? Is there any other options for this, maybe a change of CI?

Query isn't fired to often during the day, it's a batch job running few times in one hour.
Sign In or Register to comment.