Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id ED4F62E2DE7 for ; Fri, 16 Nov 2007 15:33:27 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 67782-08 for ; Fri, 16 Nov 2007 15:33:20 -0400 (AST) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.172]) by postgresql.org (Postfix) with ESMTP id 110A42E2DD6 for ; Fri, 16 Nov 2007 15:33:19 -0400 (AST) Received: by ug-out-1314.google.com with SMTP id j3so693335ugf for ; Fri, 16 Nov 2007 11:33:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; 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:sender; bh=e91M96L5QiW3+ZrDBCB+3Ju/dWPcN3vw1FimJ5rOnO4=; b=oPe4yCnFqyv4bnKMNbsIX0kskHFUzTL/xsCZJEfYVeSpXg0dqxIsL6e8KQgPHuzuunkDSqOu1DI6aZMjMZ/U/xxJo9FiZEtzg7Xs/1/GMuVvEuVnE3RcX3XjmsZcmJpbfwZI66Ih5nEjvb+cbtCfdT5vQSbuIL5a/qSYjqGxDyk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=q4SsAVH6t/+nwFOiUkoSvE61LCjHjjPcDbw5ejRNDn8sNlkxgEfeA4D48UO9eIY1WBUqjR45uM79z7BbH0HSyXVXJKcGHr4PM5R1/9/qZj2ByDvc9+uCw3VX4bvdXLJ3cdhbTeXJbY74Xuu1msmNk1a3mRwYwj4Um7t8gulxCx8= Received: by 10.78.183.15 with SMTP id g15mr2457597huf.1195241598595; Fri, 16 Nov 2007 11:33:18 -0800 (PST) Received: from ?192.168.1.33? ( [81.110.31.161]) by mx.google.com with ESMTPS id d27sm3834873nfh.2007.11.16.11.33.15 (version=SSLv3 cipher=RC4-MD5); Fri, 16 Nov 2007 11:33:17 -0800 (PST) Message-ID: <473DF073.1000503@enterprisedb.com> Date: Fri, 16 Nov 2007 19:33:07 +0000 From: Heikki Linnakangas User-Agent: Icedove 1.5.0.12 (X11/20070730) MIME-Version: 1.0 To: adrobj CC: pgsql-performance@postgresql.org Subject: Re: Clustered/covering indexes (or lack thereof :-) References: <13700848.post@talk.nabble.com> In-Reply-To: <13700848.post@talk.nabble.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200711/247 X-Sequence-Number: 27662 adrobj wrote: > This is probably a FAQ, but I can't find a good answer... > > So - are there common techniques to compensate for the lack of > clustered/covering indexes in PostgreSQL? To be more specific - here is my > table (simplified): > > topic_id int > post_id int > post_text varchar(1024) > > The most used query is: SELECT post_id, post_text FROM Posts WHERE > topic_id=XXX. Normally I would have created a clustered index on topic_id, > and the whole query would take ~1 disk seek. > > What would be the common way to handle this in PostgreSQL, provided that I > can't afford 1 disk seek per record returned? You can cluster the table, see http://www.postgresql.org/docs/8.2/interactive/sql-cluster.html. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com