[25 points] Consider the two queries below:
-- q1
select c.mid, COUNT(*)
from Movie m, Casts c
where m.id = c.mid
group by c.mid
-- q2
select m.name, COUNT(*)
from Movie m, Casts c
where m.id = c.mid
group by m.name
-
Run these two queries on the IMDB database on IISQLSRV; one is about twice
as fast as the other.
Examine the query plans for these two queries, and explain the difference
in running time.
-
The IMDB_FOREIGNKEYS
database is identical to IMDB but has foreign keys declared in Casts. Examine
the plans for the two queries on the IMDB_FOREIGNKEYS database, and explain
which one changed from the IMDB database and why.