From: David Jarvis <thangalin@gmail.com>
To: Matthew Wakeling <matthew@flymine.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Thom Brown <thombrown@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Optimize date query for large child tables: GiST or GIN?
Date: Thu, 20 May 2010 21:11:52 -0700
Message-ID: <AANLkTimjPLmnSZDe3nNBVGjJ0CGIQd_Ic8IxHb4fUG9v@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1005202322470.23895@aragorn.flymine.org>
References: <AANLkTimi_Jh4J6bLZ8lZ0cGQ0VVG7XPCKaFN9GRHd6mP@mail.gmail.com>
<AANLkTim7O3Aalp31WKwBuTufYXeUMQWkwy51nvRcI0QY@mail.gmail.com>
<AANLkTikl8wlHPJaArMWO9XWgG0vk9tununw3eUAYh1IC@mail.gmail.com>
<7767.1274385170@sss.pgh.pa.us>
<AANLkTikOEC-Gr3eqGlyGauRAZJknQEaS5DEWw-ZOcl6r@mail.gmail.com>
<7917.1274385834@sss.pgh.pa.us>
<AANLkTimLdBWaVpSF5Sc3ArT_9jcAjhNiB9WBBA4HIyXj@mail.gmail.com>
<8132.1274386738@sss.pgh.pa.us>
<AANLkTimpwoKQw2sXOl4n2lNOzZz_YpBYLKIkOhVgaTD4@mail.gmail.com>
<alpine.DEB.2.00.1005202322470.23895@aragorn.flymine.org>
Hi,
(An EXPLAIN ANALYSE would be better here). Look at the expected number of
> stations
"Nested Loop (cost=0.00..994.94 rows=4046 width=4) (actual
time=0.053..41.173 rows=78 loops=1)"
" Join Filter: ((6371.009::double precision *
sqrt((pow(radians(((c.latitude_decimal - s.latitude_decimal))::double
precision), 2::double precision) + (cos((radians(((c.latitude_decimal +
s.latitude_decimal))::double precision) / 2::double precision)) *
pow(radians(((c.longitude_decimal - s.longitude_decimal))::double
precision), 2::double precision))))) <= 25::double precision)"
" -> Index Scan using city_pkey1 on city c (cost=0.00..6.27 rows=1
width=16) (actual time=0.014..0.016 rows=1 loops=1)"
" Index Cond: (id = 5182)"
" -> Seq Scan on station s (cost=0.00..321.08 rows=12138 width=20)
(actual time=0.007..5.256 rows=12139 loops=1)"
" Filter: ((s.elevation >= 0) AND (s.elevation <= 3000))"
"Total runtime: 41.235 ms"
expects to have to touch a large proportion of the measurement table,
> therefore it thinks that it will be fastest to do a seq scan. In actual
> fact, for 78 stations, the index would be faster, but for 4046 it wouldn't.
>
This is rather unexpected. I'd have figured it would use the actual number.
> If you will be querying by season quite regularly, had you considered
> partitioning by season?
>
I have no idea what the "regular" queries will be. The purpose of the system
is to open the data up to the public using a simple user interface so that
they can generate their own custom reports. That user interface allows
people to pick year intervals, day ranges, elevations, categories
(temperature, precipitation, snow depth, etc.), and lat/long perimeter
coordinates (encompassing any number of stations) or a city and radius.
Dave
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: thangalin@gmail.com, matthew@flymine.org, tgl@sss.pgh.pa.us, thombrown@gmail.com
Subject: Re: Optimize date query for large child tables: GiST or GIN?
In-Reply-To: <AANLkTimjPLmnSZDe3nNBVGjJ0CGIQd_Ic8IxHb4fUG9v@mail.gmail.com>
References: <AANLkTimi_Jh4J6bLZ8lZ0cGQ0VVG7XPCKaFN9GRHd6mP@mail.gmail.com> <AANLkTim7O3Aalp31WKwBuTufYXeUMQWkwy51nvRcI0QY@mail.gmail.com> <AANLkTikl8wlHPJaArMWO9XWgG0vk9tununw3eUAYh1IC@mail.gmail.com> <7767.1274385170@sss.pgh.pa.us> <AANLkTikOEC-Gr3eqGlyGauRAZJknQEaS5DEWw-ZOcl6r@mail.gmail.com> <7917.1274385834@sss.pgh.pa.us> <AANLkTimLdBWaVpSF5Sc3ArT_9jcAjhNiB9WBBA4HIyXj@mail.gmail.com> <8132.1274386738@sss.pgh.pa.us> <AANLkTimpwoKQw2sXOl4n2lNOzZz_YpBYLKIkOhVgaTD4@mail.gmail.com> <alpine.DEB.2.00.1005202322470.23895@aragorn.flymine.org> <AANLkTimjPLmnSZDe3nNBVGjJ0CGIQd_Ic8IxHb4fUG9v@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