pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rodrigo De León <rdeleonp@gmail.com>
To: pgsql-sql@postgresql.org
Cc: RPK <rpk.general@gmail.com>
Subject: Re: Retrieve month from date
Date: Fri, 20 Apr 2007 11:33:30 -0500
Message-ID: <a55915760704200933j3f02ae6dp8bdf73e522aeb0f2@mail.gmail.com> (raw)
In-Reply-To: <10105471.post@talk.nabble.com>
References: <11604f180704200519h5d858f6ey1efbbccd52ccd0c9@mail.gmail.com>
	<10105471.post@talk.nabble.com>

On 4/20/07, RPK <rpk.general@gmail.com> wrote:
>
> Thanks both of you,
>
> I ran EXPLAIN command on above suggested query and got following result:
>
> "Aggregate  (cost=2.77..2.79 rows=1 width=10)"
> "  ->  Seq Scan on studentfeespayment  (cost=0.00..2.77 rows=1 width=10)"
> "        Filter: (date_part('month'::text, (recieptmonthyear)::timestamp
> without time zone) = 4::double precision)"
>
> What does this mean? Can I optimize it better?

create index lala on "StudentFeesPayment"(Extract(Month from
"ReceiptMonthYear"))

explain Select max("ReceiptNo") from "StudentFeesPayment" where
Extract(Month from "ReceiptMonthYear")=4;

Aggregate  (cost=14.97..14.98 rows=1 width=4)
  ->  Bitmap Heap Scan on "StudentFeesPayment"  (cost=4.33..14.94
rows=10 width=4)
        Recheck Cond: (date_part('month'::text,
("ReceiptMonthYear")::timestamp without time zone) = 4::double
precision)
        ->  Bitmap Index Scan on lala  (cost=0.00..4.33 rows=10 width=0)
              Index Cond: (date_part('month'::text,
("ReceiptMonthYear")::timestamp without time zone) = 4::double
precision)

See:

http://www.postgresql.org/docs/8.2/static/indexes-expressional.html



view thread (8+ messages)  latest in thread

Message-ID: <a55915760704200933j3f02ae6dp8bdf73e522aeb0f2@mail.gmail.com>
Permalink:  ../a55915760704200933j3f02ae6dp8bdf73e522aeb0f2@mail.gmail.com/
Also on:    postgresql.org/message-id/a55915760704200933j3f02ae6dp8bdf73e522aeb0f2@mail.gmail.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: rdeleonp@gmail.com, rpk.general@gmail.com
  Subject: Re: Retrieve month from date
  In-Reply-To: <a55915760704200933j3f02ae6dp8bdf73e522aeb0f2@mail.gmail.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