Re: Reordering results for a report

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Nathaniel Price <nprice(at)tesseract(dot)net>
Cc: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>, pgsql-general(at)postgresql(dot)org, pgsql-php(at)postgresql(dot)org
Subject: Re: Reordering results for a report
Date: 2003-12-13 23:47:32
Message-ID: 20031213234732.GA30707@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-php

On Fri, Dec 12, 2003 at 14:40:34 -0800,
Nathaniel Price <nprice(at)tesseract(dot)net> wrote:
> Sorry, that's not really what I'm looking for. When I said that the sort
> order could be arbitrary, I meant /arbitrary/. As in "no amount of ORDER
> BYs will save me from this one" arbitrary; the records could be in any
> order the user specifies.
>
> The idea is that in PHP I'd be using an array to keep track of the
> custom order that the results should be returned in, using the array
> index to store the sorting order and the values to store the table's
> primary key, like so (note that this isn't the code I'm using, it's just
> an example):
>
> <?php
> $sort[0] = 3; //First record to return (3 is the primary key of the record)
> $sort[1] = 1; //Second record to return
> $sort[2] = 2; //Third record to return
> ... //and so on.
> ?>

It would be possible to use this array in a query, but this wouldn't
work well for large data sets as you would be sending the whole array
back and forth a lot. Presumably the reason you want to do the sort
in the database is because the dataset is large enough that you don't
want to buffer the data in PHP in the first place.

I think the temp table solution won't be that simple either. You will
need connection pooling and some way to keep requests from the same
web session using the same postgres session.

You may want to use regular tables which are named by session id and
the have some clean up process that removes tables that are no longer
needed.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message dj trombley 2003-12-14 00:11:10 Re: Perl "with-perl" configuration option
Previous Message Andrew Rawnsley 2003-12-13 22:08:30 Re: make error Mac OS X (ar: illegal option -- s)

Browse pgsql-php by date

  From Date Subject
Next Message Greg Stark 2003-12-14 02:39:08 Re: Reordering results for a report
Previous Message scott.marlowe 2003-12-12 23:09:53 Re: Reordering results for a report