Subject | Re: Query speed is going down |
---|---|
Author | Juan Jose Ochoa |
Post date | 2005-07-02T20:45:24Z |
I've had this issue for long time and I haven't found a better
solution than to seperate it in several statements in a SP like this:
FOR Select ...
From P INNER JOIN Z
group by...
into :...
do begin
FOR SELECT ...
from T
where PK = :...
into :...;
FOR SELECT ...
from M
where PK = :...
into :...;
suspend;
end
I suppose that all the result set is defined by "P INNER JOIN Z" the
others are only "useful fields". So you go into T and M only the
minimal necessary times.
I've been evaluating FB2. and I know this issuse is going to be
solved by using derived tables and by using the execute block
statement. I already tested and works fine, just as S.P.
Anyways I still think that the optimizer should detect this scenario
and "optimeze" for it.
---
other approach:
SELECT 1
FROM Z
WHERE
DATASPRZEDAZY BETWEEN '2005-02-01' AND '2005-2-28' AND
((Z.GODZINA BETWEEN 8 AND 22) OR Z.GODZINA=0))
Depending on the results, you could separate P from Z.
ok!
I hope this help, and that this kind of tune won't be necessary in
future versions of FB.
Juan Jose.
solution than to seperate it in several statements in a SP like this:
FOR Select ...
From P INNER JOIN Z
group by...
into :...
do begin
FOR SELECT ...
from T
where PK = :...
into :...;
FOR SELECT ...
from M
where PK = :...
into :...;
suspend;
end
I suppose that all the result set is defined by "P INNER JOIN Z" the
others are only "useful fields". So you go into T and M only the
minimal necessary times.
I've been evaluating FB2. and I know this issuse is going to be
solved by using derived tables and by using the execute block
statement. I already tested and works fine, just as S.P.
Anyways I still think that the optimizer should detect this scenario
and "optimeze" for it.
---
other approach:
> P: 590210 out of 8 millHow many records and reads do you get when you do a:
> Z: 339244 out of 4 mill
> T: 590210
> M: 334822
SELECT 1
FROM Z
WHERE
DATASPRZEDAZY BETWEEN '2005-02-01' AND '2005-2-28' AND
((Z.GODZINA BETWEEN 8 AND 22) OR Z.GODZINA=0))
Depending on the results, you could separate P from Z.
ok!
I hope this help, and that this kind of tune won't be necessary in
future versions of FB.
Juan Jose.