Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 6C3F9632C61 for ; Sat, 18 Apr 2009 11:05:08 -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 93138-10 for ; Sat, 18 Apr 2009 11:04:56 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qy0-f115.google.com (mail-qy0-f115.google.com [209.85.221.115]) by mail.postgresql.org (Postfix) with ESMTP id DD727632386 for ; Sat, 18 Apr 2009 11:05:04 -0300 (ADT) Received: by qyk13 with SMTP id 13so2675890qyk.15 for ; Sat, 18 Apr 2009 07:05:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type:content-transfer-encoding; bh=a7jnmYNmAMsvrk9NTvJZ9eim7OY6vcxofQ9FFtH/7r8=; b=tlxuaTbE1bhdlepwwgf90u+FXalLlIUWLxmmzyCeDPLTIPDAehpUzOulKJflcd6LCE 2zb8en0sRtrEcyjT8CCTkt+EYxmbuiTmPUD0hrkQBS6Dx6ZObHlPxm82v13hXE6WPlwN V+Mt4shA4YSC1ijQFwnIcPrTNumw8uiwqDNoQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=PG6Scb822LbVJqoJUjyJLOg2VcRMNsPUq7gFD5qs2kqicxGCi+Fx0dN5g/bQm8n1jV CgTrJs0rul5mETL5mjyhXHOO04aArE+lM48lY08vDh1L0TusKDUG8i6yFHT08SnHDmqS iv5y5fbYiH5jiU58RMlI6wlBSAH0EwnA8REeE= MIME-Version: 1.0 Received: by 10.224.29.3 with SMTP id o3mr424279qac.96.1240063503064; Sat, 18 Apr 2009 07:05:03 -0700 (PDT) In-Reply-To: <49E9CFBF.4050808@gmail.com> References: <49E9CFBF.4050808@gmail.com> Date: Sat, 18 Apr 2009 10:05:03 -0400 X-Google-Sender-Auth: 4e7db9eb7efa1a93 Message-ID: <1d7288990904180705he9adfb7h80eeeb1110c0b68b@mail.gmail.com> Subject: Re: sorting query results From: Brew To: Piotr Mitoraj Cc: pgsql-php@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 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/7 X-Sequence-Number: 4012 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 -- Strange Brew (brew@theMode.com) Check out my Stock Option website http://www.callpix.com and my Musicians Free Classified http://www.TheMode.com