Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id EF8689FB558; Fri, 23 Mar 2007 23:28:54 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 48160-10; Fri, 23 Mar 2007 23:28:38 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) by postgresql.org (Postfix) with ESMTP id A6F6C9FB351; Fri, 23 Mar 2007 23:28:49 -0300 (ADT) Received: from Courts-MTA by gwmta.wicourts.gov with Novell_GroupWise; Fri, 23 Mar 2007 21:28:47 -0500 Message-Id: <46044683.EE98.0025.0@wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 7.0.1 Date: Fri, 23 Mar 2007 21:28:36 -0500 From: "Kevin Grittner" To: "Peter Kovacs" Cc: ,, "Tom Lane" , "Andrea Olson" , "Bill Severson" , "John Hutchins" , "Randy Peterson" , "Shannon Spranger" Subject: Re: [PERFORM] EXISTS optimization References: <4603C1A3.EE98.0025.0@wicourts.gov> <25339.1174686582@sss.pgh.pa.us> <46040DAC.EE98.0025.0@wicourts.gov> In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/1432 X-Sequence-Number: 100916 >>> On Fri, Mar 23, 2007 at 6:04 PM, in message , "Peter = Kovacs" wrote:=20 > On 3/23/07, Kevin Grittner wrote: > [...] >> That's the good news. The bad news is that I operate under a management= =20 > portability dictate which doesn't currently allow that syntax, since not = all=20 > of the products they want to >=20 > It doesn't really touch the substance, but I am curious: are you not > even allowed to discriminate between products in your code like: > if db is 'postresql' then > ... > else > ... > ? >=20 > What would be the rationale for that? =20 Anybody who's not curious about that should skip the rest of this email. =20 Management has simply given a mandate that the software be independent of = OS and database vendor, and to use Java to help with the OS independence. = I have to admit that I am the architect of the database independence = solution that was devised. (The choice of Java for the OS independence = has been very successful. We have run our bytecode on HP-UX, Windows, Sun = Solaris, and various flavors of Linux without having to compile different = versions of the bytecode. Other than when people get careless with case = sensitivity on file names or with path separators, it just drops right in = and runs. =20 For the data side, we write all of our queries in ANSI SQL in our own = query tool, parse it, and generate Java classes to run it. The ANSI = source is broken down to "lowest common denominator" queries, with all = procedural code covered in the Java query classes. So we have stored = procedures which can be called, triggers that fire, etc. in Java, issuing = SELECT, INSERT, UPDATE, DELETE statements to the database. This allows us = to funnel all DML through a few "primitive" routines which capture before = and after images and save them in our own transaction image tables. We = use this to replicate from our 72 county databases, which are the official = court record, to multiple central databases, and a transaction repository, = used for auditing case activity and assisting with failure recovery. =20 The problem with burying 'if db is MaxDB', 'if db is SQLServer', 'if db is = PostgreSQL' everywhere is that you have no idea what to do when you then = want to drop in some different product. We have a plugin layer to manage = known areas of differences which aren't handled cleanly by JDBC, where the = default behavior is ANSI-compliant, and a few dozen to a few hundred = lines need to be written to modify that default support a new database = product. (Of course, each one so far has brought in a few surprises, = making the plugin layer just a little bit thicker.) =20 So, to support some new syntax, we have to update our parser, and have a = way to generate code which runs on all the candidate database products, = either directly or through a plugin layer. If any of the products don't = support multi-value row value constructors, I have a hard time seeing a = good way to cover that with the plugin. On the subject issue, I'm pretty = sure it would actually be less work for me to modify the PostgreSQL = optimizer to efficiently handle the syntax we do support than to try to = bend row value constructors to a syntax that is supported on other = database products. =20 And, by the way, I did take a shot on getting them to commit to PostgreSQL = as the long-term solution, and relax the portability rules. No sale. = Perhaps when everything is converted to PostgreSQL and working for a while = they may reconsider. =20 -Kevin =20