Hola Yessica, bueno te entiendo con eso de los usuarios tercos, que piden reportes muchas veces un poco complicado por la herramienta que uno utiliza para el desarrollo, te cuento yo desarrollo con PHP y Postgres, y pues el php un poco como que tiene sus limitaciones, y como tu dices hay que ingeniarselas para sacar adelante el proyecto, yo tambien lo pruebo antes en el localhost, pero luego lo subo a mi servidor bueno servidor de la empresa... que esta en Linux y pues el servidor no tengo problemas, pero con lo que si tengo problemas es  con las consultas y algunas vistas y me obligaron hasta cierto punto a usar Funciones para que me ayude en algo y pues me ayudo en algo ahh pero lo principal que me faltaban eran definir algunos Indices, mira esta funcion un poco chica bueno se ve grandota por que son varias tablas a la vez :

CREATE OR REPLACE FUNCTION "public"."fu_estado_cta_cte" (varchar, varchar, varchar, varchar, date) RETURNS SETOF "public"."estado_cta_cte" AS
$body$
DECLARE
    pc_idccodso ALIAS FOR $1;
    pc_scrcndni ALIAS FOR $2;
    pc_sauccode ALIAS FOR $3;
    pc_scrccoso ALIAS FOR $4;
    pd_saufecha ALIAS FOR $5;
    rd_scoplani estado_cta_cte%rowtype;
begin
     
    FOR rd_scoplani IN SELECT '' AS idccodpl, det.steccoen AS idccodso,
        to_date(eg.stedfech, 'YYYY/MM/DD'::text) AS
        sccdfech, 'EGR' AS scctipo, CASE WHEN (det.idccodcu ~~ '5011%'::text)
        THEN det.stenmont ELSE 0.00 END AS sccoapor, CASE WHEN ((det.idccodcu
        ~~ '1411%'::text) OR (det.idccodcu ~~ '1412%'::text) OR
        (det.idccodcu ~~ '166201'::text)) THEN det.stenmont
        ELSE 0::numeric END AS sccopram, CASE WHEN (det.idccodcu ~~
        '7331%'::text) THEN det.stenmont ELSE 0::numeric END AS sccoprin, CASE
        WHEN (det.idccodcu ~~ '743101%'::text) THEN det.stenmont ELSE
        0::numeric END AS sccoprmo, CASE WHEN (((((det.idccodcu ~~
        '1661%'::text) OR (det.idccodcu ~~ '7551%'::text)) AND (det.idccodcu <>
        '166106'::character varying)) AND (det.idccodcu <> '166107'::character
        varying)) AND (det.idccodcu <> '166108'::character varying)) THEN
        det.stenmont ELSE 0::numeric END AS sccoacti, CASE WHEN ((det.idccodcu
        = '166106'::character varying) OR (det.idccodcu = '751101'::character
        varying)) THEN det.stenmont ELSE 0::numeric END AS sccomant, CASE WHEN
        ((det.idccodcu = '166107'::character varying) OR (det.idccodcu =
        '757101'::character varying)) THEN det.stenmont ELSE 0::numeric END AS
        sccofose, CASE WHEN ((det.idccodcu = '166108'::character varying) OR
        (det.idccodcu = '754101'::character varying)) THEN det.stenmont ELSE
        0::numeric END AS sccomult, det.idcegres AS idcodocu, det.stecsueg AS
        idcsucur, CASE WHEN (det.idccodcu = '141401'::character varying) THEN
        det.stenmont ELSE 0::numeric END AS sccocred, det.stenafec AS sccodeha, CASE WHEN
        (((det.idccodcu = '465102'::character varying) OR (det.idccodcu =
        '465101'::character varying)) OR (det.idccodcu = '464101'::character
        varying)) THEN det.stenmont ELSE 0::numeric END AS sccootro
FROM stecabeg eg, stedeteg det, scrsocio so WHERE (eg.idcegres = det.idcegres) AND (eg.stecsueg = det.stecsueg)
AND (eg.stectien = det.stectien) AND (so.idccodso = det.steccoen)
AND eg.stectien = 'SOCIO'::character varying AND det.stectien = 'SOCIO'::character
    varying AND eg.anulado = 0::numeric AND eg.eliminar = 0::numeric AND det.steccoen = pc_idccodso
UNION ALL
SELECT '' AS idccodpl, det.steccoen AS idccodso,
        to_date(ing.stedfech, 'YYYY/MM/DD'::text) AS
        sccdfech, 'ING' AS scctipo, CASE WHEN (det.idccodcu ~~ '5011%'::text)
        THEN det.stenmont ELSE 0.00 END AS sccoapor, CASE WHEN (((det.idccodcu
        ~~ '1411%'::text) OR (det.idccodcu ~~ '1412%'::text))) THEN det.stenmont ELSE 0::numeric END AS sccopram,
        CASE WHEN (det.idccodcu ~~ '7331%'::text) THEN det.stenmont ELSE
        0::numeric END AS sccoprin, CASE WHEN (det.idccodcu ~~ '743101%'::text)
        THEN det.stenmont ELSE 0::numeric END AS sccoprmo, CASE WHEN
        (((((det.idccodcu ~~ '1661%'::text) OR (det.idccodcu ~~ '469108%'::text) OR (det.idccodcu ~~ '7551%'::text))
        AND (det.idccodcu <> '166106'::character varying)) AND (det.idccodcu <>
        '166107'::character varying)) AND (det.idccodcu <> '166108'::character
        varying)) THEN det.stenmont ELSE 0::numeric END AS sccoacti, CASE WHEN
        ((det.idccodcu = '166106'::character varying) OR (det.idccodcu =
        '751101'::character varying)) THEN det.stenmont ELSE 0::numeric END AS
        sccomant, CASE WHEN ((det.idccodcu = '166107'::character varying) OR
        (det.idccodcu = '757101'::character varying)) THEN det.stenmont ELSE
        0::numeric END AS sccofose, CASE WHEN ((det.idccodcu =
        '166108'::character varying) OR (det.idccodcu = '754101'::character
        varying)) THEN det.stenmont ELSE 0::numeric END AS sccomult,
        det.idcingre AS idcodocu, ing.idcsucur, CASE WHEN ((det.idccodcu ~~
        '1413%'::text) OR (det.idccodcu ~~ '1414%'::text)) THEN det.stenmont
        ELSE 0::numeric END AS sccocred, det.stenafec AS sccodeha, CASE WHEN
        (((det.idccodcu = '465102'::character varying) OR (det.idccodcu =
        '465101'::character varying)) OR (det.idccodcu = '464101'::character
        varying) OR (det.idccodcu ~~ '751201%'::text))
        THEN det.stenmont ELSE 0::numeric END AS sccootro
FROM stecabin ing, stedetin det, scrsocio so WHERE (ing.idcingre = det.idcingre) AND
(ing.stectien = det.stectien) AND (ing.idcsucur = det.idcsucur) AND (so.idccodso = det.steccoen)
AND ing.stectien = 'SOCIO'::character varying AND det.stectien = 'SOCIO'::character varying AND ing.eliminar = 0::numeric AND ing.anulado = 0::numeric
    AND det.steccoen = pc_idccodso
UNION ALL
   SELECT pl.idccodpl, pl.idccodso, pl.sccdfech, pl.sccctipo AS scctipo,
           pl.sccoapor, pl.sccopram, pl.sccoprin, pl.sccoprmo, pl.sccoacti,
           pl.sccomant, pl.sccofose, pl.sccomult, '' AS idcodocu, '' AS idcsucur,
           pl.sccocred, 0 AS sccodeha, CASE WHEN pl.scondein IS NULL THEN 0.00 ELSE pl.scondein END AS sccootro
    FROM scoplani pl WHERE pl.idccodso = pc_idccodso
UNION ALL
SELECT '' AS idccodpl, ord.idccodso, ord.scrdfech AS sccdfech, 'BOLE' AS
    scctipo, 0 AS sccoapor, 0 AS sccopram, 0 AS sccoprin, 0 AS sccoprmo, 0 AS
    sccoacti, 0 AS sccomant, 0 AS sccofose, 0 AS sccomult, (
    SELECT ((((scrcabbo.scrcseri || '-'::character varying) ||
        scrcabbo.scrcnume) || '-'::character varying) || scrcabbo.idccodbo)
    WHERE (((scrcabbo.idccodbo = ord.idccodbo) AND (scrcabbo.eliminar =
        0::numeric)) AND (scrcabbo.scrnanul = 0::numeric) AND scrcabbo.idccodso = pc_idccodso)
    ) AS idcodocu, ord.idcsucur, CASE WHEN (ord.scrctipo = 'OCTO2'::character
        varying) THEN (
    SELECT scrcabbo.scrntota
    FROM scrcabbo
    WHERE (((scrcabbo.idccodbo = ord.idccodbo) AND (scrcabbo.eliminar =
        0::numeric)) AND (scrcabbo.scrnanul = 0::numeric) AND scrcabbo.idccodso = pc_idccodso)
    ) ELSE 0::numeric END AS sccocred, 0 AS sccodeha, 0 AS sccootro
FROM scrordcr ord
WHERE ord.scrctipo = 'OCTO2'::character varying AND ord.scrnesta =
    1::numeric AND ord.eliminar = 0::numeric AND ord.anulado = 0::numeric AND ord.idccodso = pc_idccodso
UNION ALL
SELECT '' AS idccodpl, ord.idccodso, ord.scrdfech AS sccdfech, 'CRED' AS
    scctipo, 0 AS sccoapor, 0 AS sccopram, 0 AS sccoprin, 0 AS sccoprmo, 0 AS
    sccoacti, 0 AS sccomant, 0 AS sccofose, 0 AS sccomult, ord.idccodoc AS
    idcodocu, ord.idcsucur, ord.scrnmoau AS sccocred, 0 AS sccodeha, 0 AS sccootro
FROM scrordcd ord
WHERE ord.scrnesta = 0::numeric AND ord.eliminar = 0::numeric AND ord.anulado = 0::numeric
AND ord.idccodso = pc_idccodso
UNION ALL
SELECT '' AS idccodpl, det.sccccoen AS idccodso,
        asi.sccdfech, 'TRAN' AS scctipo, CASE WHEN (det.idccodcu ~~
        '5011%'::text) THEN det.sccnmont ELSE 0.00 END AS sccoapor, CASE WHEN
        ((det.idccodcu ~~ '1411%'::text) OR (det.idccodcu ~~ '1412%'::text)
         OR (det.idccodcu ~~ '166201%'::text))
        THEN det.sccnmont ELSE 0::numeric END AS sccopram, CASE WHEN
        (det.idccodcu ~~ '7331%'::text) THEN det.sccnmont ELSE 0::numeric END
        AS sccoprin, CASE WHEN (det.idccodcu ~~ '743101%'::text) THEN
        det.sccnmont ELSE 0::numeric END AS sccoprmo, CASE WHEN
        (((((det.idccodcu ~~ '1661%'::text) OR (det.idccodcu ~~ '7551%'::text))
        AND (det.idccodcu <> '166106'::character varying)) AND (det.idccodcu <>
        '166107'::character varying)) AND (det.idccodcu <> '166108'::character
        varying)) THEN det.sccnmont ELSE 0::numeric END AS sccoacti, CASE WHEN
        ((det.idccodcu = '166106'::character varying) OR (det.idccodcu =
        '751101'::character varying)) THEN det.sccnmont ELSE 0::numeric END AS
        sccomant, CASE WHEN ((det.idccodcu = '166107'::character varying) OR
        (det.idccodcu = '757101'::character varying)) THEN det.sccnmont ELSE
        0::numeric END AS sccofose, CASE WHEN ((det.idccodcu =
        '166108'::character varying) OR (det.idccodcu = '754101'::character
        varying)) THEN det.sccnmont ELSE 0::numeric END AS sccomult,
        det.idccodas AS idcodocu, asi.idcsucur, CASE WHEN ((det.idccodcu ~~
        '1413%'::text) OR (det.idccodcu ~~ '1414%'::text)) THEN det.sccnmont
        ELSE 0::numeric END AS sccocred, det.sccnafec AS sccodeha, CASE WHEN
        (((det.idccodcu = '465102'::character varying) OR (det.idccodcu =
        '465101'::character varying)) OR (det.idccodcu = '464101'::character
        varying)) THEN det.sccnmont ELSE 0::numeric END AS sccootro
FROM (scccabas asi JOIN sccdetas det ON ((asi.idccodas = det.idccodas)))
WHERE upper((asi.sccctiop)::text) = 'AT'::text AND det.idccodtd = '038'::character varying AND asi.eliminar = 0::numeric AND asi.sccnanul = 0::numeric AND det.sccccoen = pc_idccodso LOOP
        RETURN NEXT rd_scoplani;
    END LOOP;
    RETURN;
END
$body$
LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;


bueno te la paso completa pa que la veas y como veras asi hay muchas mas pero resulta que algunas vistas que tengo se demoran mucho en mostrar y muchas veces el navegador me bota del sistema se corta es un error muy comun que tengo en estos dias, necesito ayudaaaaaa!!!!!!! Urgente, quisiera saber cual se ejecuta mas rapido una funcion a la que le envio parametros y me retorna ragistros o un vista haber si me puedes ayudar.

suelo escribir muy poco siempre jejeje gracias bye




El amor es el significado último de todo lo que nos rodea. No es un simple sentimiento, es la verdad, es la alegría que está en el origen de toda creación. .:: J @ v i e r ::.