Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 6746B63290D for ; Sat, 18 Apr 2009 10:04:06 -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 83312-05 for ; Sat, 18 Apr 2009 10:03:56 -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 755E562DBDD for ; Sat, 18 Apr 2009 10:04:04 -0300 (ADT) Received: by fxm22 with SMTP id 22so1797275fxm.19 for ; Sat, 18 Apr 2009 06:04:02 -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:subject:content-type :content-transfer-encoding; bh=O6sLNYsMlpOawn1xjOUwy2hlITrXM2B2///6+Eqab7A=; b=FXoM4L3ankSWNj4rMJPkd+EY429uVQmFFhla5a0VLL3rCAaqkw1QO1FJTAfazIbd9w RWu+Ogbv0t7hOQ3/w/ztaH8NYSLgUMJgygGZ0Y/0Ul6DKRKm7XtzpGKUGM4mRmq7giA5 oa074PzOVXvfNzB4JDRftqHYcUgV4r0WCsVQ4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=c21DL+BU0eHx+h45KwchVRkUPHfSpZPJ8TWrIKaVCu8G3msB5NoYLExMJYPqCtqgvO 0y9v7/1hCskJyhz52iov/5gvzNOaLqBKZySt55l+ytddSEwtB8H18Es4JuiAt9140i7A +KU5FPSgmbwj23lbqxNnh0tIMKT3odAqx9hRk= Received: by 10.86.59.2 with SMTP id h2mr2691651fga.30.1240059842132; Sat, 18 Apr 2009 06:04:02 -0700 (PDT) Received: from ?192.168.0.100? (as67-120.tontut.fi [94.237.67.120]) by mx.google.com with ESMTPS id 12sm2161655fgg.12.2009.04.18.06.04.01 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 18 Apr 2009 06:04:01 -0700 (PDT) Message-ID: <49E9CFBF.4050808@gmail.com> Date: Sat, 18 Apr 2009 16:03:59 +0300 From: Piotr Mitoraj User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 To: pgsql-php@postgresql.org Subject: sorting query results 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/6 X-Sequence-Number: 4011 Hi, failing to find the straight-forward answer on the web I hope to find some advice in here. I want to display the table fetched from the postgres database. The headers of the columns are links used to sort the data. Like the functionality you have on ebay when you sort according to price or time left. I recognized two ways of doing that: 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. Regards, Piotr