From: jkoceniak@mediamath.com
To: pgsql-bugs@postgresql.org
Subject: BUG #14411: Issue with using OFFSET
Date: Thu, 03 Nov 2016 20:29:12 +0000
Message-ID: <20161103202912.15989.78255@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
The following bug has been logged on the website:
Bug reference: 14411
Logged by: Jamie Koceniak
Email address: jkoceniak@mediamath.com
PostgreSQL version: 9.4.6
Operating system: Linux
Description:
Query performance decreases as the OFFSET increases.
Bad Query:
SELECT t1.id, ( SELECT count ( * ) FROM site_list_sites t4 WHERE t1.id =
t4.site_list_id ) AS sites_count
FROM site_lists t1
WHERE t1.organization_id IN ( SELECT distinct organization_id FROM
user_permissions ( 2385 ))
ORDER BY t1.created_on DESC LIMIT 100 OFFSET 200;
With offset set to 100, query returns in 92ms
Query Plan (offset = 100):
https://explain.depesz.com/s/nnPd
offset = 200, query take 9.8 seconds
Query plan (offset=200)
https://explain.depesz.com/s/MQAS
--
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: jkoceniak@mediamath.com
Subject: Re: BUG #14411: Issue with using OFFSET
In-Reply-To: <20161103202912.15989.78255@wrigleys.postgresql.org>
References: <20161103202912.15989.78255@wrigleys.postgresql.org>
* 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