Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 490499F95EB for ; Thu, 13 Sep 2007 10:32:03 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 15063-02 for ; Thu, 13 Sep 2007 10:32:00 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.175]) by postgresql.org (Postfix) with ESMTP id 351E19F9B18 for ; Thu, 13 Sep 2007 10:32:00 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id j3so422464ugf for ; Thu, 13 Sep 2007 06:31:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=fehoOCJE770kK1XWpXWSPeA80+a7nDn61mfuOqja5u4=; b=lwV/RTI3JmTV5R95hdkNuzhiKx2fZmZ72ffXE9moy/kapPJVh4uuLu3/VE98fgfCaDIUQG3/7nnWYKDHC/IeVdOpjBrGNjj+8w/gtRfAet7vcgKUvf3m2vCR53Tw+C2DjcN17Y3TOYlm0gGCUqqd6dQeuulCRDrkmlvkCTnwYnY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=mT5r/NFtVCREVfC8G5Zh0nSDUYXygs8etuP1kjppHWkQKIYEyg02Y3EJ6rwj1m8h8UTX5GvYVTOTa5H+/f387FyN0JkrB/RK2stYiWVNHLYgV6Wlqj7BWrq/AhH+FpB21n6uM28W6ktIxFOfjRc44sLszuWPY72Zlv9oOMlIQLc= Received: by 10.78.81.20 with SMTP id e20mr341701hub.1189690318075; Thu, 13 Sep 2007 06:31:58 -0700 (PDT) Received: by 10.78.145.8 with HTTP; Thu, 13 Sep 2007 06:31:58 -0700 (PDT) Message-ID: <88daf38c0709130631y13e8a185ufd9b9b4c1c9d1ee8@mail.gmail.com> Date: Thu, 13 Sep 2007 15:31:58 +0200 From: "Alexander Staubo" To: "Patrice Castet" Subject: Re: Clustered tables improves perfs ? Cc: pgsql-performance@postgresql.org In-Reply-To: <46E9353A.9080602@agematis.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <46E9353A.9080602@agematis.com> X-Google-Sender-Auth: c0b10e396c70a3eb X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/242 X-Sequence-Number: 26787 On 9/13/07, Patrice Castet wrote: > I wonder if clustering a table improves perfs somehow ? As I understand it, clustering will help cases where you are fetching data in the same sequence as the clustering order, because adjacent rows will be located in adjacent pages on disk; this is because hard drives perform superbly with sequential reads, much less so with random access. For example, given a table foo (v integer) populated with a sequence of integers [1, 2, 3, 4, ..., n], where the column v has an index, and the table is clustered on that index, a query such as "select v from foo order by v" will read the data sequentially from disk, since the data will already be in the correct order. On the other hand, a query such as "select v from foo order by random()" will not be able to exploit the clustering. In other words, clustering is only useful insofar as your access patterns follow the clustering order. Alexander.