From: | Hellmuth Vargas <hivs77(at)gmail(dot)com> |
---|---|
To: | Micky Khan <mcanchas(at)hotmail(dot)com> |
Cc: | FORO POSTGRES <pgsql-es-ayuda(at)postgresql(dot)org> |
Subject: | Re: Consulta sobre fechas TimeStamp |
Date: | 2018-05-18 19:32:09 |
Message-ID: | CAN3Qy4qYaMF9HxsQBE0pvngF3bUVW884waA1=ocht7Vseh2TDg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Hola Lista
Tenemos dos maneras básicas de hacer una consulta que involucra timestamp
contra un date:
1. date(timestamp)
Select * from mitabla where date(Fecha_TIMESTAMP) = cast('2018-05-18'
as date)
Para tablas con gran cantidad de registros implica un indice sobre
date(Fecha_TIMESTAMP)
2. between, mi preferido
Select * from mitabla where Fecha_TIMESTAMP between
cast('2018-05-18' as timestamp) and cast('2018-05-18' as timestamp)+
cast('1 day' as interval)
para tablas con gran cantidad de registros implica un indice sobre
Fecha_TIMESTAMP
Ahora bien, sin mas informacion como que tan grande es las tabla y como
están distribuidos los datos, para poder sugerir un particionamiento sobre
el campo Fecha_TIMESTAMP por ejemplo no podría aportar mucho mas...
El 18 de mayo de 2018, 13:37, Micky Khan<mcanchas(at)hotmail(dot)com> escribió:
> Buenas.
>
>
> Una consulta; como es la manera correcta de tal manera que sea lo mas
> rápida posible de ejecutar una consulta
>
>
> Select * from mitabla where Fecha_TIMESTAMP = '2018-05-18'
>
>
>
> Mi campo fecha a consultar es de tipo TIMESTAMP y los datos que se envian
> para la consulta es de tipo DATE.
>
>
> Gracias por vuestra ayuda.
>
>
>
>
--
Cordialmente,
Ing. Hellmuth I. Vargas S.
From | Date | Subject | |
---|---|---|---|
Next Message | Andrés P.P. | 2018-05-18 20:26:01 | Re: Replicación M-M.... BDR, plogical.... en PG 9.5 |
Previous Message | Micky Khan | 2018-05-18 18:37:12 | Consulta sobre fechas TimeStamp |