Skip site navigation (1) Skip section navigation (2)

Re: sorting query results

From: Brew <brew(at)theMode(dot)com>
To: Piotr Mitoraj <piotr(dot)mitoraj(at)gmail(dot)com>
Cc: pgsql-php(at)postgresql(dot)org
Subject: Re: sorting query results
Date: 2009-04-18 14:05:03
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-php

> I recognized two
> ways of doing that:   (sorting results)
> 1. Issue a new query to the database each time the specific sorting was
> requested. In other words, let the database do the sorting and fetch the
> results.
> 2. Save the table into php array and and use php built-in functions to sort
> and refresh the table.
> Which of those methods would be most desired in terms of performance and
> according to "the best practices"?
> What would be possible drawbacks/advantages of those methods.

I'd do it in within the database query, it's just a little bit of
programming, probably just add 'ORDER BY' to your statement.  Possibly
more, but if you have a real complicated query you'll be spending a
bunch of time getting it right anyway.

If it's slow, then you start to optimize the query.

At any rate, that's the way I do it.....


Strange Brew (brew(at)theMode(dot)com)

Check out my Stock Option website
and my Musicians Free Classified

In response to


pgsql-php by date

Next:From: Piotr MitorajDate: 2009-04-18 14:34:26
Subject: Re: sorting query results
Previous:From: Piotr MitorajDate: 2009-04-18 13:03:59
Subject: sorting query results

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group