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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-sql by date

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