0

I have a table which has 2163 rows and clustered index on id column.

I run the following queries:

select id
from ticket_attach
where id = 1

select id
from ticket_attach
where id = 2

select id
from ticket_attach
where id = 3

Here is my plan cache:

enter image description here

Well, when I execute 1st query, I result in creating both adhoc plan and prepared plan.

I thought that under simple parameterization, the next two queries where id=2 and id=3 will use only prepared plan. Yes, those queries really used prepared plan, BUT in addition to that, they created adhoc plans. I wonder why SQL Server created those plans if it used already prepared plan. What it the purpose of creating them and taking place of plan cache?

Rauf Asadov
  • 1,313
  • 14
  • 36

0 Answers0