From: Andreas Joseph Krogh <andreas@visena.com>
To: pgsql-performance@postgresql.org
Subject: Re: OFFSET/LIMIT - Disparate Performance w/ Go application
Date: Thu, 12 Jun 2014 21:48:48 +0200 (CEST)
Message-ID: <VisenaEmail.20d.24e885a4d4b9ec15.146919ddd21@tc7-on> (raw)
In-Reply-To: <24297.1402585086@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>
På torsdag 12. juni 2014 kl. 16:58:06, skrev Tom Lane <tgl@sss.pgh.pa.us
<mailto:tgl@sss.pgh.pa.us>>: Matt Silverlock <matt@eatsleeprepeat.net> writes:
> Hi all. This might be tricky in so much as there���s a few moving parts
(when isn���t there?), but I���ve tried to test the postgres side as much as
possible.
> Trying to work out a potential database bottleneck with a HTTP application
(written in Go):
> Pages that render HTML templates but don���t perform DB queries can hit
~36k+ req/s
> Pages that perform a SELECT on a single row net about ~6.6k req/s:
db.Get(l, "SELECT * FROM listings WHERE id = $1 AND expiry_date >
current_date", l.Id)
> Pages that SELECT multiple rows with OFFSET and LIMIT conditions struggle
to top 1.3k req/s
You don't show us exactly what you're doing with OFFSET/LIMIT, but I'm
going to guess that you're using it to paginate large query results.
That's basically always going to suck: Postgres has no way to implement
OFFSET except to generate and then throw away that number of initial rows.
If you do the same query over again N times with different OFFSETs, it's
going to cost you N times as much as the base query would. Are there any
plans to make PG implement OFFSET more efficiently, so it doesn't have to "read
and throw away"? I used SQL Server back in 2011 in a project and seem to
remember they implemented offset pretty fast. Paging in a resultset of millions
was much faster than in PG. -- Andreas Jospeh Krogh CTO / Partner - Visena AS
Mobile: +47 909 56 963 andreas@visena.com <mailto:andreas@visena.com>
www.visena.com <https://www.visena.com; <https://www.visena.com;
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: andreas@visena.com
Subject: Re: OFFSET/LIMIT - Disparate Performance w/ Go application
In-Reply-To: <VisenaEmail.20d.24e885a4d4b9ec15.146919ddd21@tc7-on>
* 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