Subject | Re: SQL Performance problem |
---|---|
Author | GrumpyRain |
Post date | 2004-11-24T01:26:04Z |
> >Employee
> Adam,
>
> I am not sure you are right here...
>
> Views do use the index too...
>
> In some cases (like views with agregates) it's not possible (in the
> future I think this will be fixed) but as general rule, a query against
> a view will use the same indices as if the query was against the
> original tables.
>
> see you !
>
ID
Name
Address
v_EmployeeName
ID,
Name
(
select ID, Name
from Employee
)
1000 records in this table
run
select Name
from v_Employee
where ID < 50
in IBPlanalyzer and look at how many records it checks. Again it is OK
for a couple of hundred records, but when you have 10000 records in
the table, the difference is measurable.
We now would implement that sort of thing using
SP_EmployeeName
(
MaxID integer
)
returns
(
Name varchar(50)
)
as
declare variable vname varchar(50);
begin
for select Name
from Employee
where ID < :MaxID
into :vName
do
begin
:name = :vName;
end
etc
then you can say
select Name
from SP_EmployeeName(50);
> --
>
> Alexandre Benson Smith
> Development
> THOR Software e Comercial Ltda.
> Santo Andre - Sao Paulo - Brazil
> www.thorsoftware.com.br