From: David Jaquay <djaquay@gmail.com>
To: josh@agliodbs.com
Cc: pgsql-performance@postgresql.org
Subject: Re: Query across a date range
Date: Fri, 7 Jan 2005 15:04:28 -0500
Message-ID: <ad4aa5a805010712047409fce9@mail.gmail.com> (raw)
In-Reply-To: <200501071135.11229.josh@agliodbs.com>
References: <20050107182106.6CBEC5AF685@svr4.postgresql.org>
<ad4aa5a805010711171a3c1696@mail.gmail.com>
<200501071135.11229.josh@agliodbs.com>
'explain analyze' output is below. I have done analyze recently, and
am using pg 7.4.2 on SuSE 9.1. I'd be curious to know how to "a
nestloop indexscan" to try it out.
Thanks,
Dave
mydb=> explain analyze select * from line_items t, sales_tickets s
where writtenDate >= '12/01/2002' and writtenDate <= '12/31/2002' and
t.ticketid = s.ticketId and s.storeId = 1;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------
Hash Join (cost=93865.46..114054.74 rows=19898 width=28) (actual
time=25419.088..32140.217 rows=23914 loops=1)
Hash Cond: ("outer".ticketid = "inner".ticketid)
-> Index Scan using line_items_written on line_items t
(cost=0.00..3823.11 rows=158757 width=16) (actual
time=100.621..3354.818 rows=169770 loops=1)
Index Cond: ((writtendate >= '2002-12-01'::date) AND
(writtendate <= '2002-12-31'::date))
-> Hash (cost=89543.50..89543.50 rows=626783 width=12) (actual
time=22844.146..22844.146 rows=0 loops=1)
-> Seq Scan on sales_tickets s (cost=0.00..89543.50
rows=626783 width=12) (actual time=38.017..19387.447 rows=713846
loops=1)
Filter: (storeid = 1)
Total runtime: 32164.948 ms
(8 rows)
On Fri, 7 Jan 2005 11:35:11 -0800, Josh Berkus <josh@agliodbs.com> wrote:
> Can you run EXPLAIN ANALYZE instead of just EXPLAIN? That will show you the
> discrepancy between estimated and actual costs, and probably show you what
> needs fixing.
Also, Tom Lane wrote:
> Could we see EXPLAIN ANALYZE, not just EXPLAIN, results?
>
> Also, have you ANALYZEd lately? If the estimated row counts are at all
> accurate, I doubt that forcing a nestloop indexscan would improve the
> situation.
>
> Also, what PG version is this?
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-performance@postgresql.org
Cc: djaquay@gmail.com, josh@agliodbs.com
Subject: Re: Query across a date range
In-Reply-To: <ad4aa5a805010712047409fce9@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