Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 53CD7632C85 for ; Wed, 6 May 2009 19:27:25 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 54442-07 for ; Wed, 6 May 2009 19:27:23 -0300 (ADT) X-Greylist: delayed 00:29:25.672671 by SQLgrey-1.7.6 Received: from outmail136072.authsmtp.net (outmail136072.authsmtp.net [62.13.136.72]) by mail.postgresql.org (Postfix) with ESMTP id 8EDE6632C06 for ; Wed, 6 May 2009 19:27:23 -0300 (ADT) Received: from mail-c193.authsmtp.com (mail-c193.authsmtp.com [62.13.128.118]) by punt9.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id n46LvgiB081270; Wed, 6 May 2009 22:57:42 +0100 (BST) Received: from [192.168.0.2] (85-211-67-243.dyn.gotadsl.co.uk [85.211.67.243]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id n46LvfPc093999; Wed, 6 May 2009 22:57:41 +0100 (BST) Subject: Re: Very strange performance decrease when reusing a PreparedStatement From: Simon Riggs To: Roland Roberts Cc: pgsql-jdbc@postgresql.org In-Reply-To: <49FDEB97.6050800@astrofoto.org> References: <5C2E1645-73B6-4509-96CD-FA77869516AB@noopsis.fr> <49F71EDD.2070200@opencloud.com> <02437794-A78D-449C-843F-B823195F9623@noopsis.fr> <491f66a50905030310j5b4cdcd8jbf4f6e757c2ba580@mail.gmail.com> <49FDEB97.6050800@astrofoto.org> Content-Type: text/plain Date: Wed, 06 May 2009 22:59:54 +0100 Message-Id: <1241647194.6109.52.camel@ebony.2ndQuadrant> Mime-Version: 1.0 X-Mailer: Evolution 2.12.0 Content-Transfer-Encoding: 7bit X-Server-Quench: ec1f7293-3a88-11de-8a51-002264978518 X-AuthRoute: OCdxZQATClZOTQEd DAteCiNZVAwpPBRK HVkIKg5MJUcNSQVJ NksadBtFaANbYFhI HGQLW11EUl97XGR/ bwsfZQBDYEtPQQNt TkpNQU1QEQdtHhxP WBoYLl8kF1ZGcX15 bE8sX3lZXQovJkcr RUxdFnAFNG9odWEe BBVFf1JRcR5Kfh1H bFR2U3sIYG1JBC9q VzwRExoaCH1hJT5E ChoRN1sUTktDBjMm SRcYGDwpFkBNSyg4 NREvMVNUA0YcNA0o PEY6WFQXexZwazVE EllEGiJVHEUIWycu AAVGNV9p X-Authentic-SMTP: 61633235383639.pelican.dmpriest.net.uk:1562/Kp X-Report-SPAM: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200905/41 X-Sequence-Number: 19591 On Sun, 2009-05-03 at 15:08 -0400, Roland Roberts wrote: > At least PostgreSQL has the ability to tell the parser to reparse > every time you ask it to prepare the statement. Oracle doesn't. The > solution for Oracle isn't relevant, but the real point here is that > your code may have to become smarter to help out the optimizer. We > reparse on every execution, but can't control Oracle's server-side > cache. PostgreSQL lets you control that with prepareThreshold=0. If > we'd had that option with Oracle, we would have had an easy solution. > I'd say PostgreSQL's implementation for this case is a good one. We have a good feature there, definitely. Although there is still more to be done. Oracle's cursor_sharing features are slightly ahead of Postgres, specifically around the "SIMILAR" option. We talked a few years back about an "Option node" that would select sub-plans at runtime based upon the actual values of the bind variable. Nobody's got around to doing anything with that yet. -- Simon Riggs www.2ndQuadrant.com PostgreSQL Training, Services and Support