Re: Sobre VACUUM

From: Juanky Moral <juanky(dot)moral(at)gmail(dot)com>
To: Aldo Alexander Leyva Alvarado <aleyva2004(at)gmail(dot)com>
Cc: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: Sobre VACUUM
Date: 2005-12-24 01:06:46
Message-ID: 463a53a40512231706s4f452f8dtfa046d95f02727dc@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

On 12/23/05, Aldo Alexander Leyva Alvarado <aleyva2004(at)gmail(dot)com> wrote:
> Cual seria el tipo de datos a retornar?
> int, float, record, etc, etc, etc , TABLE? hay Table?
metros_ultimo (table)
>
> El día 23/12/05, Juanky Moral < juanky(dot)moral(at)gmail(dot)com> escribió:
> > On 12/23/05, Aldo Alexander Leyva Alvarado < aleyva2004(at)gmail(dot)com> wrote:
> > > Una funcion que retorna un cursor?
> > > Por que ese MAQUINAS_METROS retorna una tabla.
> > > Que funcion de pondria para retornar esa tabla?
> >
> > PL/pgSQL functions can also be declared to return a "set", or table,
> > of any data type they can return a single instance of. Such a function
> > generates its output by executing RETURN NEXT for each desired element
> > of the result set.
> > Mira esta página para ver también las ventajas de usar funciones:
> >
> http://www.postgresql.org/docs/8.1/interactive/plpgsql.html#PLPGSQL-ADVANTAGES
> > >
> > >
> > >
> > > El día 23/12/05, Aldo Alexander Leyva Alvarado <aleyva2004(at)gmail(dot)com>
> > > escribió:
> > > > Buenas Tardes Lista
> > > > Una consulta, tengo BD POSTGRESQL 8.1 Sobre un Slackware 10.2, es una
> BD
> > > de pruebas, sobre ella hago diversas consultas, tenia un SQL que me
> tomaba
> > > aprox 3 segundos en obtener resultados, en general estaba en ese tiempo
> 3-4,
> > > luego hice un VACUUM a la toda la BD el mismo SQL se ejecutaba el 1-2
> > > segundos, el problema esta que si el SQL consulta registros mas antiguos
> el
> > > tiempo que toma es muy alto, demasiado, eso paso despues del VACUUM,
> > > anteriormente no tomaba ese tiempo. Por lo que percibi el VACUUM me
> > > favorecio enormemente sobre registros mas actuales, pero me perjudico de
> > > igual forma para registros mas viejos.
> > > >
> > > > SELECT ma.id_maquina, me.fecha, ma.flg_noduplicar,
> ma.flg_contador_soles ,
> > > me.id_moneda, me.cant_creditos, me.denominacion, mo.simbolo AS moneda
> FROM
> > > maquinas ma, maquinas_ext me, monedas mo, (SELECT mu.id_maquina AS
> > > mu_id_maquina, mu.n_metros_ultimo AS mu_n_metros_ultimo FROM
> metros_ultimo
> > > mu WHERE mu.id_local=84 AND mu.fecha_conteo='2005-12-21' AND
> > > mu.n_metros_ultimo=(SELECT MAX(n_metros_ultimo) FROM metros_ultimo WHERE
> > > id_maquina=mu.id_maquina AND fecha_conteo='2005-12-21' AND id_local=84))
> AS
> > > MAQUINAS_METROS WHERE MAQUINAS_METROS.mu_id_maquina= ma.id_maquina AND
> > > ma.id_maquina=me.id_maquina AND mo.id_monedas=me.id_moneda AND
> > > me.fecha=(SELECT MAX(fecha) FROM maquinas_ext WHERE id_maquina=
> ma.id_maquina
> > > AND fecha<='2005-12-21 23:59:59')
> > > > Este SQL me toma Aprox, 107.595 ms (ni un segundo)
> > > >
> > > > SELECT ma.id_maquina, me.fecha, ma.flg_noduplicar,
> ma.flg_contador_soles ,
> > > me.id_moneda, me.cant_creditos, me.denominacion, mo.simbolo AS moneda
> FROM
> > > maquinas ma, maquinas_ext me, monedas mo, (SELECT mu.id_maquina AS
> > > mu_id_maquina, mu.n_metros_ultimo AS mu_n_metros_ultimo FROM
> metros_ultimo
> > > mu WHERE mu.id_local=2 AND mu.fecha_conteo='2005-11-02' AND
> > > mu.n_metros_ultimo=(SELECT MAX(n_metros_ultimo) FROM metros_ultimo WHERE
> > > id_maquina= mu.id_maquina AND fecha_conteo='2005-11-02' AND id_local=2))
> AS
> > > MAQUINAS_METROS WHERE MAQUINAS_METROS.mu_id_maquina=ma.id_maquina AND
> > > ma.id_maquina=me.id_maquina AND mo.id_monedas=me.id_moneda AND
> > > me.fecha=(SELECT MAX(fecha) FROM maquinas_ext WHERE id_maquina=
> > > ma.id_maquina AND fecha<='2005-11-02 23:59:59')
> > > > Este SQL me toma Aprox, 7232.951 ms (mas de 7 segundos)
> > > >
> > > > Algun consejo, agradezcon de antemano por sus respuestas
> > > >
> > > > Saludos
> > > >
> > > >
> > >
> > >
> >
> >
> > --
> > Juanky Moral - www.juancarlosmoral.es/blog
> >
>
>

--
Juanky Moral - www.juancarlosmoral.es/blog

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Mario Gonzalez 2005-12-24 04:49:34 Re: Licencia
Previous Message Efren Alejandro Barroso 2005-12-24 01:05:44 RE: [pgsql-es-ayuda] Iteración con Cursores. Ayuda!!!