pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: mallah@trade-india.com
To: sszabo@megazone23.bigpanda.com
Cc: mallah@trade-india.com
Cc: pgsql-sql@postgresql.org
Subject: Re: SQL help for efficient time handling..
Date: Sat, 22 Mar 2003 23:17:42 +0530 (IST)
Message-ID: <1081.219.65.230.11.1048355262.squirrel@mail.trade-india.com> (raw)
In-Reply-To: <20030322081350.R1246-100000@megazone23.bigpanda.com>
References: <200303221332.33121.mallah@trade-india.com>
	<20030322081350.R1246-100000@megazone23.bigpanda.com>



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@postgresql.org)



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




view thread (6+ messages)

Message-ID: <1081.219.65.230.11.1048355262.squirrel@mail.trade-india.com>
Permalink:  ../1081.219.65.230.11.1048355262.squirrel@mail.trade-india.com/
Also on:    postgresql.org/message-id/1081.219.65.230.11.1048355262.squirrel@mail.trade-india.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mallah@trade-india.com, sszabo@megazone23.bigpanda.com
  Subject: Re: SQL help for efficient time handling..
  In-Reply-To: <1081.219.65.230.11.1048355262.squirrel@mail.trade-india.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox