From: Piotr Mitoraj <piotr.mitoraj@gmail.com>
To: Brew <brew@theMode.com>
Cc: pgsql-php@postgresql.org
Subject: Re: sorting query results
Date: Sat, 18 Apr 2009 17:34:26 +0300
Message-ID: <49E9E4F2.10008@gmail.com> (raw)
In-Reply-To: <1d7288990904180705he9adfb7h80eeeb1110c0b68b@mail.gmail.com>
References: <49E9CFBF.4050808@gmail.com>
<1d7288990904180705he9adfb7h80eeeb1110c0b68b@mail.gmail.com>
Piotr......
>
>> 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.....
>
> brew
>
Thanks Brew! The queries I am using are not that complicated (yet). So
for now I ll just stick to this method.
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: piotr.mitoraj@gmail.com, brew@theMode.com
Subject: Re: sorting query results
In-Reply-To: <49E9E4F2.10008@gmail.com>
References: <49E9CFBF.4050808@gmail.com> <1d7288990904180705he9adfb7h80eeeb1110c0b68b@mail.gmail.com> <49E9E4F2.10008@gmail.com>
* 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