Subject | RE: [firebird-support] How to optimize view to work faster |
---|---|
Author | Alan McDonald |
Post date | 2007-12-09T23:04Z |
> Hi,Show us the plan that is being used.
>
> I have two tables robfaktura (invoice header) and robfakturas
> (invoice items), and wiev based on these two tables:
>
> SELECT Z.ID, Z.SESIJA, Z.UIP, Z.TIP, Z.OBJEKAT, Z.KOMITENTI,
> Z.KOMOBJEKTI, Z.KOMITENTIP, Z.BROJ, Z.BROJS, Z.DATUM,
> Q.NVREDNOST, Q.SVREDNOST, Q.RVREDNOST, Q.OVREDNOST,
> Q.PVREDNOST, Q.KVREDNOST, Q.NVVREDNOST, Q.UVREDNOST
> FROM ROBFAKTURA Z
> JOIN ( SELECT X. ID, SUM(Y.NVREDNOST) AS NVREDNOST, SUM(Y.SVREDNOST)
> AS SVREDNOST, SUM(Y.RVREDNOST) AS RVREDNOST, SUM(Y.OVREDNOST) AS
> OVREDNOST,
> SUM(Y.PVREDNOST) AS PVREDNOST, SUM(Y.KVREDNOST) AS
> KVREDNOST, SUM(Y.NVVREDNOST) AS NVVREDNOST, SUM(Y.KVREDNOST -
> X.POPUSTVR - X.AVANS1 - X.AVANS2 - X.AVANS3) AS UVREDNOST
> FROM ROBFAKTURA X
> LEFT OUTER JOIN ROBFAKTURAS Y ON Y.ROBFAKTURA = X.ID
> GROUP BY X.ID) Q ON Q.ID = Z.ID
>
> I have one simple question for Firebird experts, how to optimize this
> viev (sql statement) if header table have more then milion records
> and everytime when I call this view I must wait about 5-10 minutes
> even I get empty table as resultset?
> Or someone have smarter solution than mine?
>
> Thnaks in advance...
Also tell us what component set you are using.
This sort of delay is the result of
Wrong plan, or
Missing indexes, or
A component set which is set to retrieve all instead of only retrieving the
first bufer load of records
(or a combination of the above)
Alan