Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id CCA37632BD9 for ; Sat, 18 Apr 2009 11:34:32 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 99159-05 for ; Sat, 18 Apr 2009 11:34:21 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-fx0-f174.google.com (mail-fx0-f174.google.com [209.85.220.174]) by mail.postgresql.org (Postfix) with ESMTP id 0A9AE632AAC for ; Sat, 18 Apr 2009 11:34:29 -0300 (ADT) Received: by fxm22 with SMTP id 22so1820831fxm.19 for ; Sat, 18 Apr 2009 07:34:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=Tiq9PzKWXET944q5aogKILhHcbUPu70MTuFU9s2v54Q=; b=QMXDPSvx9uWxQe4Ln9zGNxCNAlHOzxn/WcHqAXaURZYcnuiokwzf22X9JfUFrlsN7B M2UK1JPjmvWU4yQnsQSLD75TDipLTTDHyntFmNdmGc9xy2G9Ry1sQOXJTNlIQ7aXt7Hg QuX7rfzB/QcsSzu1EYSL4fPiGXuhhMMMO4rHM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=oG89LYVlvv6DWhWYjwlCF5HmChfcb14tTEhy4TxgY0aJDk87PKh9PAaVVJm0Oj7T+/ mXCD9oNARSTEOo5HbyfxXA987oSQ+o3pj5V+wZYFm5FK1kovrLyz85h2RfEkMigk2+jt vxZa9HIF6jl9ku9DPHvVWQCjkMp4OI4fj8LXk= Received: by 10.204.70.135 with SMTP id d7mr3435742bkj.87.1240065267980; Sat, 18 Apr 2009 07:34:27 -0700 (PDT) Received: from ?192.168.0.100? (as67-120.tontut.fi [94.237.67.120]) by mx.google.com with ESMTPS id 35sm5901532fkt.3.2009.04.18.07.34.27 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 18 Apr 2009 07:34:27 -0700 (PDT) Message-ID: <49E9E4F2.10008@gmail.com> Date: Sat, 18 Apr 2009 17:34:26 +0300 From: Piotr Mitoraj User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 To: Brew CC: pgsql-php@postgresql.org Subject: Re: sorting query results References: <49E9CFBF.4050808@gmail.com> <1d7288990904180705he9adfb7h80eeeb1110c0b68b@mail.gmail.com> In-Reply-To: <1d7288990904180705he9adfb7h80eeeb1110c0b68b@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/8 X-Sequence-Number: 4013 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.