From: Tom Lane <tgl@sss.pgh.pa.us>
To: Aaron Bono <postgresql@aranya.com>
Cc: PostgreSQL SQL List <pgsql-sql@postgresql.org>
Subject: Re: Sequence vs. Index Scan
Date: Sat, 05 May 2007 20:22:50 -0400
Message-ID: <29507.1178410970@sss.pgh.pa.us> (raw)
In-Reply-To: <bf05e51c0705051405p29ee139fn30c9979f3772a1d4@mail.gmail.com>
References: <bf05e51c0705051405p29ee139fn30c9979f3772a1d4@mail.gmail.com>
"Aaron Bono" <postgresql@aranya.com> writes:
> 9. -> Seq Scan on branch (cost=0.00..4.72 rows=1
> width=1281) (actual time=130129.988..157492.057 rows=1 loops=1)
> 10. Filter: ((start_day <= now()) AND
> ((end_day IS NULL) OR (end_day >= now())) AND (branch_id =
> get_branch_for_zip('22151'::character varying)))
There is something *awfully* wacko about that entry --- the fact that
the cost estimate is less than 5 units means that the planner thinks
there's 4 or fewer pages; either that's way wrong or the
get_branch_for_zip function is taking enormous amounts of time per row.
Have you tried timing that function on its own?
One possible reason for the performance difference is if you have
get_branch_for_zip marked as stable in one database and volatile in the
other --- volatile would prevent it from being used in an indexqual as
you'd like.
regards, tom lane
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: tgl@sss.pgh.pa.us, postgresql@aranya.com
Subject: Re: Sequence vs. Index Scan
In-Reply-To: <29507.1178410970@sss.pgh.pa.us>
* 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