On 4/20/07, RPK <[EMAIL PROTECTED]> 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

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to