Re: Speed Up Offset and Limit Clause

From: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
To: "Craig A(dot) James" <cjames(at)modgraph-usa(dot)com>
Cc: Christian Paul Cosinas <cpc(at)cybees(dot)com>, 'PFC' <lists(at)peufeu(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Speed Up Offset and Limit Clause
Date: 2006-05-17 19:04:01
Message-ID: 20060517190400.GV26212@pervasive.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Tue, May 16, 2006 at 07:20:12PM -0700, Craig A. James wrote:
> >Why I want to use offset and limit is for me to create a threaded
> >application so that they will not get the same results.
>
> In order to return rows 10000 to 15000, it must select all rows from zero
> to 15000 and then discard the first 10000 -- probably not what you were
> hoping for.
>
> You might add a "thread" column. Say you want to run ten threads:

Another possibility is partitioning the table. If you do that using
inheritance-based partitioning, you could just select directly from
different partition tables, which probably be even faster than using a
single table. The downside is it's more work to setup.
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Jim C. Nasby 2006-05-17 19:20:34 Re: Optimizer: limit not taken into account
Previous Message Jim C. Nasby 2006-05-17 19:00:01 Re: [PERFORM] Performance incorporate with JReport