Dnia Tue, Sep 13, 2005 at 08:15:03PM +0200 Andrzej Banach napisał(a):
> >
> > {customers = CUSTOMERS}
> > {for (r=0; r<number(customers); r++)}\
> > { if (customers[r].balance < (- multiplier * OBLIGATIONS[r].value))}\
> > { customers[r].lastname} {customers[r].name}\t{customers[r].balance}
> > { /if}\
> >
> > czy tak wygląda po poprawkach? nie możesz używać nigdzie CUSTOMERS
> >
> dokladnie tak - czas wykonania podstawienia {customers = CUSTOMERS} to
> 12s. Po wrzuceniu calego zapytania czyli
>
> {CUST = SELECT customers.id AS id, customers.lastname AS lastname, \
> customers.name AS name, customers.status AS status, \
> address, zip, city, email, phone1, phone2, phone3, ten, ssn, \
> customers.info AS info, message, \
> SUM(nodes.warning) AS warning, SUM(nodes.access) AS access, \
> ROUND(COALESCE(SUM((type * -2 + 7) * value), 0.00)/( \
> CASE COUNT(DISTINCT nodes.id) \
> WHEN 0 THEN 1 \
> ELSE COUNT(DISTINCT nodes.id) END \
> ),2) AS balance \
> FROM customers \
> LEFT JOIN cash ON (customers.id = customerid) \
> LEFT JOIN nodes ON (customers.id = ownerid) \
> WHERE deleted = 0 \
> GROUP BY customers.id, lastname, customers.name, \
> customers.status, address, zip, city, email, phone1, \
> phone2, phone3, ten, ssn, customers.info, message}\
>
> bezposrednio do script i uzywaniu {for (r=0; r<number(CUST); r++)}
> czas ponizej 1ms.
> Tak wiec narazie mozna sobie radzic piszac zapytanie w script
> i nie uzywac tych rozszerzen.
>
A jednak... za szybko chyba odpowiadam a nie sprawdzam informacji jakie
podaje... moj blad...
Samo zapytanie:
SELECT customers.id AS id,
customers.lastname AS lastname,
customers.name AS name,
ROUND(COALESCE(SUM((type * -2 + 7) * value), 0.00)/(CASE
COUNT(DISTINCT nodes.id) WHEN 0 THEN 1 ELSE COUNT(DISTINCT nodes.id) END
),2) AS balance
FROM customers
LEFT JOIN cash ON (customers.id = customerid)
LEFT JOIN nodes ON (customers.id = ownerid)
WHERE deleted = 0
GROUP BY customers.id, lastname, customers.name
wpisane nawet w phpmyadmin trwa 7.5276 sek.
Tak wiec nic dziwnego ze parser tak dlugo kompiluje...
Tak wiec to nie zaden blad tylko tak jest..
A moze ktos powie jak uproscic te zapytanie by wyszukiwanie bilansu
i danych abonenta twalo krocej??
ps - juz dzisiaj nic nie pisze bo tylko tworze zamieszanie:P
--
Andrzej Banach
net-komp.net.pl