pg.ddx.io pgsql-performance@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Josh Berkus <josh@agliodbs.com>
To: pgsql-performance@postgresql.org
Subject: Re: ORDER BY, LIMIT and indexes
Date: Mon, 05 Aug 2013 18:22:16 -0700
Message-ID: <52004FC8.3070102@agliodbs.com> (raw )
In-Reply-To: <WM!ef3b6773f9be9426ab3306b828cc4d2f7edadb60ff2a40e2c3b3b44d43322973359f634e7976d4731ba0fb718523c050!@asav-3.01.com >
References: <CAF-QHFW2S7XHMFY-nCSbBRsFQFC--3NyVqOcW7SMeNAs28NDcQ@mail.gmail.com >
<WM!ef3b6773f9be9426ab3306b828cc4d2f7edadb60ff2a40e2c3b3b44d43322973359f634e7976d4731ba0fb718523c050!@asav-3.01.com >
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>
Ivan,
> Or, more generally, is there some set of circumstances under which the
> catastrophic scenario will happen?
Yes:
SELECT * FROM table ORDER BY id DESC LIMIT 10 OFFSET 100000
This is the "high offset" problem, and affects all databases which
support applications with paginated results, including non-relational
ones like SOLR. The basic problem is that you can't figure out what is
OFFSET 100000 without first sorting the first 100000 results.
The easiest solution is to limit the number of pages your users can
"flip through". Generally anyone asking for page 10,000 is a bot
screen-scraping your site, anyway.
--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com
--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance
view thread (17+ messages) latest in thread
Message-ID: <52004FC8.3070102@agliodbs.com>
Permalink: ../52004FC8.3070102@agliodbs.com/
Also on: postgresql.org/message-id/52004FC8.3070102@agliodbs.com
copy link · copy postgr.es
reply 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: josh@agliodbs.com
Subject: Re: ORDER BY, LIMIT and indexes
In-Reply-To: <52004FC8.3070102@agliodbs.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