I kind of have a feel for why the view is slower: The where clause is probably not applied at the same time. The results do seem to be the same, though. I am not sure what I can do about this, short of not using a view...which is not ideal, as I added the view to avoid code repetition, and I don't want to remove it if it isn't necessary.
Any suggestions for to change the way I am doing this so that I can use a view like in Command 1 but still have my query be executed as quickly as it is executed in command 2?
declare @foo varchar(50)
set @foo = 'be%'
ALTER VIEW [dbo].[wpvw_v]
AS
select distinct [name]
from kvgs kvg left join cdes cde
on kvg.kvgi = cde.kgi
group by [name], cde.kgi, kvg.mU
having count(cde.kgi) >= 2 or kvg.mU = 1 or
exists (select [name] from FP x where x.name = kvg.name)
--Command 1: Takes 7 seconds
select [name] from wpvw_v where name like @foo
--Command 2: Takes 1 second
SELECT DISTINCT kvg.name
FROM dbo.kvgs AS kvg LEFT JOIN
dbo.cdes AS cde ON kvg.kvgi = cde.kgi
where name like @foo
GROUP BY kvg.name, cde.kgi, kvg.mU
HAVING (COUNT(cde.kgi) >= 2) OR
(kvg.mU = 1) OR
EXISTS
(SELECT Name
FROM dbo.FP AS x
WHERE (Name = kvg.name))