If a query is only pulling back one value from a table using 3 columns in an index, does adding it to the index improve performance by not pulling back data rows?
SELECT readings_reading
INTO lc_initial_read
FROM readings WITH (INDEX(i_readings_miu_id_read_date))
WHERE site_id = li_site_id AND
readings_miu_id = li_miu_id AND
readings_date = ld_initial_read_date;
The 3 fields in the where clause are indexed. Would it help to add readings_reading?
Also, what about the following:
SELECT max(readings_date)
FROM neptune.readings WITH (INDEX(i_readings_miu_id_read_date))
WHERE site_id = li_site_id AND
readings_miu_id = li_miu_id AND
readings_date <= ld_last_read_date AND
readings_reading <> lc_last_read;
Would it help to have the reading in the index?