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
------------------------------------------------------------------------------------------------------------------------------------------
IndexScan 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=1loops=1) Index Cond: (sql_time = (date_trunc('minute'::text, now()))::time without time zone)Total runtime:
0.11msec
(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@postgresql.org)
-----------------------------------------
Get your free web based email at trade-india.com. "India's Leading B2B eMarketplace.!"
http://www.trade-india.com/