Re: ECPG patch N+1, fix auto-prepare - Mailing list pgsql-hackers

From Boszormenyi Zoltan
Subject Re: ECPG patch N+1, fix auto-prepare
Date
Msg-id 4B278CD7.6010803@cybertec.at
Whole thread Raw
In response to Re: ECPG patch 4.1, out-of-scope cursor support in native mode  (Boszormenyi Zoltan <zb@cybertec.at>)
Responses Re: ECPG patch N+1, fix auto-prepare  (Michael Meskes <meskes@postgresql.org>)
List pgsql-hackers
Hi,

here's another patch that aims to fix auto-prepare.

The reason is, that in the project porting from Informix,
a small test case that used a cursor and two small SELECTs
issued for every record retrieved by the cursor showed that
for this case, the ESQL compiled binary finished about 60%
faster then the ECPG compiled counterpart running against
PostgreSQL. The cursor retrieved a little over 60'000 records.

We have modified the test code to prepare the two SELECTs
and now the new test code was faster then the ESQL/Informix
code, parsing and planning the two small SELECTs had such
an accumulated runtime effect.

Then we looked at ECPG and discovered that it already has
the auto-prepare feature, and tried it using "ecpg -r prepare".

However, it turned out that the auto-prepare feature is
over-zealous, it tries to prepare statements that are rejected
by the server, returning -400 (ECPG_PGSQL). One example is

  char *sqlstr = "SELECT ...";

  EXEC SQL PREPARE stmt1 FROM :sqlstr;
  EXEC SQL DECLARE cur1 CURSOR FOR stmt1;

The attached patch is an attempt to make the preprocessor
only pass ECPGst_prepnormal when it's definitely appropriate,
i.e. only for DELETE, INSERT, UPDATE and SELECT(-like)
statements in the grammar.

Comments?

Best regards,
Zoltán Böszörményi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/


Attachment

pgsql-hackers by date:

Previous
From: Greg Stark
Date:
Subject: Re: Range types
Next
From: Andrew Dunstan
Date:
Subject: Re: Fwd: pgAdmin III: timestamp displayed in what time zone?