Re: Advice Wanted on Selecting Multi-row Data Requests in 10-Row Blocks - Mailing list pgsql-general

From Sam Mason
Subject Re: Advice Wanted on Selecting Multi-row Data Requests in 10-Row Blocks
Date
Msg-id 20080630125131.GS2572@frubble.xen.chris-lamb.co.uk
Whole thread Raw
In response to Re: Advice Wanted on Selecting Multi-row Data Requests in 10-Row Blocks  (Ragnar <gnari@hive.is>)
Responses Re: Advice Wanted on Selecting Multi-row Data Requests in 10-Row Blocks  ("Merlin Moncure" <mmoncure@gmail.com>)
List pgsql-general
On Fri, Jun 27, 2008 at 08:22:35PM +0000, Ragnar wrote:
> let us assume your resultset has a a unique column pk, and is ordered on
> column o:
>
> next page
>   select * from foo where (o,pk)>(o,?) order by o limit 10;
> (where the ? is the last pk value in previous select)
>
> this method will be able to make use of an index on (o,pk)

Hum, I think I must be missing something.  I'm not sure why you're
comparing 'o' to itself and you're not putting any ordering constraint
on the primary key.  I think the query should look closer to:

    SELECT * FROM foo WHERE (o,pk)>($1,$2) ORDER BY o,pk LIMIT 10;

Or am I going mad?

I'm expecting a table structure somewhat like:

  CREATE TABLE foo (
    pk    TEXT PRIMARY KEY,
    value TEXT,
    o     INT  NOT NULL
  );

  CREATE INDEX foo_ord_idx ON foo (o,pk);


  Sam

pgsql-general by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: "The tuple structure of a not-yet-assigned record is indeterminate."
Next
From: Bill Moran
Date:
Subject: Re: freebsd + postgresql 8.3.3 = 100% of cpu usage on stats collector?