I have two similar queries that generate the same query plan, except that one query plan executes a Clustered Index Scan 1316 times, while the other executes it 1 time.
The only difference between the two queries is different date criteria. The long running query actually narrower date criteria, and pulls back less data.
I have identified some indexes that will help with both queries, but I just want to understand why the Clustered Index Scan operator is executing 1316 times on a query that is virtually the same as the one that where it executes 1 time.
I checked the statistics on the PK that is being scanned, and they are relatively up to date.
Original query:
select distinct FIR_Incident.IncidentID
from FIR_Incident
left join (
select incident_id as exported_incident_id
from postnfirssummary
) exported_incidents on exported_incidents.exported_incident_id = fir_incident.incidentid
where FI_IncidentDate between '2011-06-01 00:00:00.000' and '2011-07-01 00:00:00.000'
and exported_incidents.exported_incident_id is not null
Generates this plan:

After narrowing the date range criteria:
select distinct FIR_Incident.IncidentID
from FIR_Incident
left join (
select incident_id as exported_incident_id
from postnfirssummary
) exported_incidents on exported_incidents.exported_incident_id = fir_incident.incidentid
where FI_IncidentDate between '2011-07-01 00:00:00.000' and '2011-07-02 00:00:00.000'
and exported_incidents.exported_incident_id is not null
Generates this plan:

FI_IncidentDate between '2011-07-01 00:00:00.000' and '2011-07-02 00:00:00.000'criteria and since then there have been a disproportionate number of inserts in that range. It estimates only 1.07 executions will be needed for that date range. Not the 1,316 that ensue in actuality. – Martin Smith Dec 06 '11 at 22:49