> create temporary table t (
> id SERIAL primary key,
> ts timestamp not null default now()
> );
* add date( ts ) as a field and index date = now()::date.
* Depending on the amount of data in your table the date
may not be seletive enough to be worth using, at which
On 24 October 2018 at 07:14, Mike Rylander wrote:
>
> On Tue, Oct 23, 2018 at 5:38 AM Lutz Horn wrote:
> > I am looking for a way to select all timestamps that are "today" in an
> > index friendly way. This select should not depend on the concrete value
> > of "today".
>
> Per TFM,
On Tue, Oct 23, 2018 at 5:38 AM Lutz Horn wrote:
>
> Hi,
>
> I am looking for a way to select all timestamps that are "today" in an
> index friendly way. This select should not depend on the concrete value
> of "today".
>
Per TFM, https://www.postgresql.org/docs/10/static/datatype-datetime.html
On Tue, Oct 23, 2018 at 3:57 PM, Lutz Horn wrote:
> On Tue, Oct 23, 2018 at 03:50:14PM +0200, Francisco Olarte wrote:
>> It'is not as the problem was stated. Although ts defaulted to now(),
>> and it is probably defaulted, nothing prohibits him from inserting
>> timestamps in the future.
> Yes,
On Tue, Oct 23, 2018 at 03:50:14PM +0200, Francisco Olarte wrote:
> It'is not as the problem was stated. Although ts defaulted to now(),
> and it is probably defaulted, nothing prohibits him from inserting
> timestamps in the future.
Yes, this table is only used as an example for the technical
On Tue, Oct 23, 2018 at 3:05 PM, Hellmuth Vargas wrote:
...
>> Then use current_date:
>>
>>where ts >= current_date
>> and ts < current_date + 1
>
> this is equally valid?
>
> where ts >= current_date
It'is not as the problem was stated. Although ts defaulted to now(),
and it is
Hi
El mar., 23 de oct. de 2018 a la(s) 05:41, Thomas Kellerer (
spam_ea...@gmx.net) escribió:
> Lutz Horn schrieb am 23.10.2018 um 12:19:
> > Hi Thomas,
> >
> > On Tue, Oct 23, 2018 at 12:11:55PM +0200, Thomas Kellerer wrote:
> >> I typically use:
> >>
> >> where ts >= date '2018-10-23'
> >>
Lutz Horn schrieb am 23.10.2018 um 12:19:
> Hi Thomas,
>
> On Tue, Oct 23, 2018 at 12:11:55PM +0200, Thomas Kellerer wrote:
>> I typically use:
>>
>> where ts >= date '2018-10-23'
>> and ts < date '2018-10-23' + 1
>
> But here the date is an explicit value. Francisco reworded my question:
Hi Thomas,
On Tue, Oct 23, 2018 at 12:11:55PM +0200, Thomas Kellerer wrote:
> I typically use:
>
> where ts >= date '2018-10-23'
> and ts < date '2018-10-23' + 1
But here the date is an explicit value. Francisco reworded my question:
> if your definition of today is 'same value as now()
Lutz Horn schrieb am 23.10.2018 um 11:38:
> I can of course make an explicit select for `ts` values that are
> "today":
>
> select ts, id
> from t
> where ts >= '2018-10-23T00:00:00'::timestamp
>and ts <= '2018-10-23T23:59:59'::timestamp;
>
> This uses an Bitmap Index Scan
Hi Francisco,
On Tue, Oct 23, 2018 at 12:05:17PM +0200, Francisco Olarte wrote:
> 1st remark. Do NOT use closed interval for timestamps. Always use
> half-open or you'll run into problems
Good point, thanks.
> where ts >= date_trunc('day',now())
> and ts < date_trunc('day',now()+'1 day')
Hi Lutz.
On Tue, Oct 23, 2018 at 11:38 AM, Lutz Horn wrote:
> I am looking for a way to select all timestamps that are "today" in an
> index friendly way. This select should not depend on the concrete value
> of "today".
> Given a table
> create temporary table t (
> id SERIAL primary
Hi,
I am looking for a way to select all timestamps that are "today" in an
index friendly way. This select should not depend on the concrete value
of "today".
Given a table
create temporary table t (
id SERIAL primary key,
ts timestamp not null default now()
);
with some
13 matches
Mail list logo