X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8D263D1DB0B for ; Sun, 7 Mar 2004 15:02:13 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 65058-02 for ; Sun, 7 Mar 2004 11:02:15 -0400 (AST) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2EF15D1DB23 for ; Sun, 7 Mar 2004 11:02:11 -0400 (AST) Received: from [134.22.68.25] (dyn-68-25.tor.dsl.tht.net [134.22.68.25]) by tht.net (Postfix) with ESMTP id 8D20276A36; Sun, 7 Mar 2004 10:02:16 -0500 (EST) Subject: Re: speeding up a select with C function? From: Rod Taylor To: David Teran Cc: PgSQL Performance ML In-Reply-To: <7F2B9EA0-702C-11D8-9DA8-000A95C496AC@cluster9.com> References: <7F2B9EA0-702C-11D8-9DA8-000A95C496AC@cluster9.com> Content-Type: text/plain Message-Id: <1078671774.57624.52.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Sun, 07 Mar 2004 10:02:55 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/89 X-Sequence-Number: 5945 > I have run vacuum analyze before executing the statements. I wonder now > if there is any chance to speed this up. Is this an active table for writes? You may want to take a look at CLUSTER. In some circumstances, it can take an order of magnitude off the query time by allowing less pages to be retrieved from disk. Other than that, if you're willing to drop performance of all queries not hitting the table to speed up this one, you can pin the index and table into memory (cron job running a select periodically to ensure it sticks). Shrink the actual data size (Drop the OID column, use a smallint instead of an integer, etc.) One final option is to alter PostgreSQL into possibly doing a sudo-sequential scan on the table when reading indexes, rather than pulling data from the table in a random order as it is found in the index. This is a rather complex project, but doable. http://momjian.postgresql.org/cgi-bin/pgtodo?performance