From: Emre Hasegeli <emre@hasegeli.com>
To: Burgess, Freddie <FBurgess@Radiantblue.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: PostgreSQL 9.3.4 Query Problems
Date: Mon, 21 Jul 2014 18:33:49 +0300
Message-ID: <20140721153349.GA66435@hasegeli-2.local> (raw)
In-Reply-To: <3BBE635F64E28D4C899377A61DAA9FE034EE454B@NBSVR-MAIL01.radiantblue.local>
References: <3BBE635F64E28D4C899377A61DAA9FE034EE454B@NBSVR-MAIL01.radiantblue.local>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
> Query planner is not selecting the most efficient index, can anything be done to correct this problem?
Trimmed explain outputs:
> -> Index Scan using sidx_sponser_report_y2014m06
> Index Cond: (sponser_location && ...
> Filter: ((origin_date_time >= ...
> Rows Removed by Filter: 3849011
> Total runtime: 63913.610 ms
> -- Then I disable the spatial index
> -> Index Scan using idx_sessiondatetime_rpi_sponser_report_y2014m06
> Index Cond: ((session_uid = ...
> Filter: ((sponser_location && ...
> Rows Removed by Filter: 1128161
> Total runtime: 1124.355 ms
It looks like a problem caused by selectivity estimation. PostgreSQL
will choose the index which will return less rows. The second index
actually returns less rows than the first one, but probably
PostgreSQL does not know about it. There is more chance that
the selectivity estimation function of the && operator misguides
the planner. I do not know about PostGIS, but selectivity estimation
functions for geometrical data types in the core are just stubs
returning constants. So, I would not expect much.
Best solution I can think of is to avoid that kind of queries.
pgsql-general@, pgsql-performance@ or maybe PostGIS mailing lists
seems like a better place to ask for help.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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-bugs@postgresql.org
Cc: emre@hasegeli.com, FBurgess@Radiantblue.com
Subject: Re: PostgreSQL 9.3.4 Query Problems
In-Reply-To: <20140721153349.GA66435@hasegeli-2.local>
References: <3BBE635F64E28D4C899377A61DAA9FE034EE454B@NBSVR-MAIL01.radiantblue.local> <20140721153349.GA66435@hasegeli-2.local>
* 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