Skip site navigation (1) Skip section navigation (2)

Re: SQL help for efficient time handling..

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Rajesh Kumar Mallah <mallah(at)trade-india(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: SQL help for efficient time handling..
Date: 2003-03-22 16:17:19
Message-ID: 20030322081350.R1246-100000@megazone23.bigpanda.com (view raw or flat)
Thread:
Lists: pgsql-sql
On Sat, 22 Mar 2003, Rajesh Kumar Mallah wrote:

> To get current_time_id  i use a query like
> SELECT  time_id from time_dimension where sql_time=date_trunc('minute' , cast(now() as time without time zone) );
>
> it works but uses seq_scan
> Seq Scan on time_dimension  (cost=0.00..35.00 rows=5 width=4) (actual time=4.75..8.16 rows=1 loops=1)
>    Filter: ((sql_time)::interval = date_trunc('minute'::text, ((now())::time without time zone)::interval))
>  Total runtime: 8.20 msec

How about something like:

select time_id from time_dimension where sql_time=
 cast(date_trunc('minute', now()) as time);


In response to

Responses

pgsql-sql by date

Next:From: Sethi Tarun-ETS017Date: 2003-03-22 16:26:07
Subject: Re: newline character in SQL
Previous:From: Tom LaneDate: 2003-03-22 16:10:59
Subject: Re: ALTER TABLE does not raises WARNING/ERROR

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group