Also falls das hilft sind hier mal meine Views die ich benutze.
der View call_destination ist der den ich bei dem explain aufgerufen habe
Code:
CREATE OR REPLACE VIEW asr AS
SELECT (call_zustande.anzahl::numeric(10,2) / call_alle.count::numeric(10,2) * 100::numeric)::numeric(10,2) AS "numeric", call_zustande."location"
FROM call_zustande, call_alle
WHERE call_zustande."location" = call_alle."location";
CREATE OR REPLACE VIEW call_alle AS
SELECT call_view."location", count(*) AS count
FROM call_view
GROUP BY call_view."location";
CREATE OR REPLACE VIEW call_desti AS
SELECT grouped_calls.dauer, ( SELECT destination.dialcode
FROM destination
WHERE grouped_calls.ausgangsnummer ~~ (destination.dialcode || '%'::text)
ORDER BY char_length(destination.dialcode) DESC
LIMIT 1) AS "location"
FROM ( SELECT call.ausgangsnummer, call.dauer
FROM call) grouped_calls;
CREATE OR REPLACE VIEW call_destination AS
SELECT call_desti."location", destination.name, count(*) AS count, sum(call_desti.dauer) / 60000 AS dauer, max(asr."numeric") AS sum
FROM destination, call_desti, asr
WHERE destination.dialcode = call_desti."location" AND asr."location" = call_desti."location"
GROUP BY call_desti."location", destination.name;
CREATE OR REPLACE VIEW call_zustande AS
SELECT count(*) AS anzahl, call_view."location"
FROM call_view
WHERE call_view.dauer > 0
GROUP BY call_view."location";
ich hab keine Idexe, weil mein SQL buch meint, dass bei dem Typ Text, den ich für den Vergleich ja brauche kein Index funktionieren würde. Stimmt das?
Lesezeichen