From: | hubert depesz lubaczewski <depesz(at)depesz(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Problem with planner |
Date: | 2011-08-08 16:53:17 |
Message-ID: | 20110808165317.GA23581@depesz.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, Aug 08, 2011 at 12:51:40PM -0400, Tom Lane wrote:
> hubert depesz lubaczewski <depesz(at)depesz(dot)com> writes:
> > and we have a query:
> > select count(*) from objects where state='active'::text and ending_tsz <= ( select now() - '1 day'::interval );
>
> Try getting rid of the sub-select. There might have been a reason to do
> it like that ten years ago, but these days it's a guaranteed
> pessimization.
looks like even worse plan:
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------
Aggregate (cost=9168023.89..9168023.90 rows=1 width=0)
-> Bitmap Heap Scan on objects (cost=336429.41..9147670.19 rows=8141478 width=0)
Recheck Cond: (state = 'active'::text)
Filter: (ending_tsz <= (now() - '1 day'::interval))
-> Bitmap Index Scan on objects_stat_user_id_creation_tsz (cost=0.00..334394.04 rows=10064868 width=0)
Index Cond: (state = 'active'::text)
(6 rows)
Best regards,
depesz
--
The best thing about modern society is how easy it is to avoid contact with it.
http://depesz.com/
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2011-08-08 17:23:39 | Re: table / query as a prameter for PL/pgSQL function |
Previous Message | Tom Lane | 2011-08-08 16:51:40 | Re: Problem with planner |