Re: SQL help for efficient time handling..

From: <mallah(at)trade-india(dot)com>
To: <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: <mallah(at)trade-india(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: SQL help for efficient time handling..
Date: 2003-03-22 17:47:42
Message-ID: 1081.219.65.230.11.1048355262.squirrel@mail.trade-india.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hey it Worked!! ,

tradein_clients=# explain analyze select time_id from general.time_dimension where sql_time=
cast(date_trunc('minute', now()) as time); QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------ Index Scan using time_dimension_sql_time_key on time_dimension (cost=0.00..3.02 rows=1 width=4)
(actual time=0.06..0.06 rows=1 loops=1) Index Cond: (sql_time = (date_trunc('minute'::text, now()))::time without time zone)
Total runtime: 0.11 msec
(3 rows)

tradein_clients=#

>
> 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);
>
>
> ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off
> all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)

-----------------------------------------
Get your free web based email at trade-india.com.
"India's Leading B2B eMarketplace.!"
http://www.trade-india.com/

In response to

Browse pgsql-sql by date

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