X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id ED591DA6B2 for ; Thu, 22 Sep 2005 09:47:59 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 54939-02 for ; Thu, 22 Sep 2005 12:47:56 +0000 (GMT) Received: from smtp1.freeserve.com (smtp1.wanadoo.co.uk [193.252.22.158]) by svr1.postgresql.org (Postfix) with ESMTP id 552BCDA6B0 for ; Thu, 22 Sep 2005 09:47:56 -0300 (ADT) Received: from me-wanadoo.net (nullmx.civet.com [127.0.0.1]) by mwinf3016.me.freeserve.com (SMTP Server) with ESMTP id BE88CC400086; Thu, 22 Sep 2005 14:47:58 +0200 (CEST) Received: from 192.168.0.102 (modem-3521.llama.dialup.pol.co.uk [217.135.189.193]) by mwinf3016.me.freeserve.com (SMTP Server) with ESMTP id 59ECFC400082; Thu, 22 Sep 2005 14:47:58 +0200 (CEST) X-ME-UUID: 20050922124758368.59ECFC400082@mwinf3016.me.freeserve.com Subject: Re: SELECT LIMIT 1 VIEW Performance Issue From: Simon Riggs To: K C Lau Cc: pgsql-performance@postgresql.org In-Reply-To: <6.2.1.2.0.20050922181009.02c36ca8@localhost> References: <6.2.1.2.0.20050615100524.04f9d6a8@localhost> <6.2.1.2.0.20050922102035.07bcf2e0@localhost> <1127378456.4145.76.camel@localhost.localdomain> <6.2.1.2.0.20050922181009.02c36ca8@localhost> Content-Type: text/plain Organization: 2nd Quadrant Date: Thu, 22 Sep 2005 13:48:04 +0100 Message-Id: <1127393284.4145.109.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-3) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.052 required=5 tests=[AWL=0.002, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200509/237 X-Sequence-Number: 14545 On Thu, 2005-09-22 at 18:40 +0800, K C Lau wrote: > We use similar views as base views throughout our OLTP system to get the > latest time-based record(s). So it is quite impossible to use summary > tables etc. Are there other ways to do it? > > The subquery would pinpoint the record(s) with the composite primary key. > Both MS Sql and Oracle do not have such performance problem. So this > problem is effectively stopping us from migrating to PostgreSQL. > > Any suggestions would be most appreciated. Even if this were fixed for 8.1, which seems unlikely, would you be able to move to that release immediately? ISTM you have two choices, in priority, complexity and time/cost order 1) custom mods to your app 2) custom mods to PostgreSQL Maybe its possible to reconstruct your query with sub-sub-selects so that you have a correlated query with manually pushed down clauses, which also references a more constant base view? Is a 51ms query really such a problem for you? Best Regards, Simon Riggs