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 4299DDA7D0 for ; Thu, 22 Sep 2005 11:40:25 -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 84291-08 for ; Thu, 22 Sep 2005 14:40:20 +0000 (GMT) Received: from wmail05dat.netvigator.com (unknown [218.102.48.220]) by svr1.postgresql.org (Postfix) with ESMTP id A6294DA7C7 for ; Thu, 22 Sep 2005 11:40:20 -0300 (ADT) Received: from n2.netvigator.com ([218.102.147.167]) by wmail05dat.netvigator.com (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP id <20050922144024.YHBC18019.wmail05dat.netvigator.com@n2.netvigator.com>; Thu, 22 Sep 2005 22:40:24 +0800 Message-Id: <6.2.1.2.0.20050922221846.02c45fb8@localhost> X-Mailer: QUALCOMM Windows Eudora Version 6.2.1.2 Date: Thu, 22 Sep 2005 22:39:29 +0800 To: Simon Riggs From: K C Lau Subject: Re: SELECT LIMIT 1 VIEW Performance Issue Cc: pgsql-performance@postgresql.org In-Reply-To: <1127393284.4145.109.camel@localhost.localdomain> 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> <1127393284.4145.109.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.525 required=5 tests=[AWL=-0.367, DNS_FROM_RFC_POST=1.376, FROM_ENDS_IN_NUMS=0.516] X-Spam-Level: * X-Archive-Number: 200509/239 X-Sequence-Number: 14547 At 20:48 05/09/22, Simon Riggs wrote: >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? Yes. In fact when we first developed our system a few years ago, we tested on MS7.0, Oracle 8 and PG 7.1.1 and we did not hit that problem. When we try again with PG 8.0, the performance becomes unbearable, but other areas appear ok and other queries are often faster than MS Sql2k. >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? We would be most happy to try them if we have some example views or pointers. >Is a 51ms query really such a problem for you? Unfortunately yes, as our target performance is in the high hundreds of transactions per sec. And 51 ms is already the best case for a single select, with everything cached in memory immediately after the same select which took 390 ms on a quiet system. >Best Regards, Simon Riggs Best regards, KC.