| From: | Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> |
|---|---|
| To: | GUSTAVO MARTIN OCAMPO <gocampo79(at)hotmail(dot)com> |
| Cc: | pgsql-ayuda(at)tlali(dot)iztacala(dot)unam(dot)mx |
| Subject: | Re: [Pgsql-ayuda] indices... |
| Date: | 2003-11-10 17:20:50 |
| Message-ID: | 20031110172050.GE6483@dcc.uchile.cl |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-es-ayuda |
On Mon, Nov 10, 2003 at 03:22:02PM +0000, GUSTAVO MARTIN OCAMPO wrote:
> Hola lista, tengo una tabla llamada basemovibanco de la forma:
> test=>explain analyze select distinct extract (year from
> basemovibanco.fecha_vencimiento) as fecha;
> Hay alguna manera de optimizar esta consulta?
Hum ... prueba con algo como
CREATE FUNCTION extract_year(date) RETURNS int AS 'return extract(year
from $1);' IMMUTABLE STRICT LANGUAGE sql;
CREATE INDEX bmb_yr_idx ON basemovibanco (extract_year(fecha_vencimiento));
Luego
SELECT distinct extract_year(fecha_vencimiento) as fecha FROM basemovibanco;
etc. Cocinar apropiadamente.
--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
Hi! I'm a .signature virus!
cp me into your .signature file to help me spread!
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Gunnar Wolf | 2003-11-10 19:26:43 | Re: [Pgsql-ayuda] Cursos de Software Libre |
| Previous Message | Roberto Andrade Fonseca | 2003-11-10 17:19:43 | [Pgsql-ayuda] Open Source 2003 |