pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Boszormenyi Zoltan <zb@cybertec.at>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Michael Meskes <meskes@postgresql.org>
Cc: Noah Misch <noah@leadboat.com>
Cc: Peter Eisentraut <peter_e@gmx.net>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: PG Hackers <pgsql-hackers@postgresql.org>
Cc: Heikki Linnakangas <hlinnakangas@vmware.com>
Cc: Bruce Momjian <bruce@momjian.us>
Cc: Hans-Jürgen Schönig <hs@cybertec.at>
Subject: Re: ECPG FETCH readahead, was: Re: ECPG fixes
Date: Wed, 04 Dec 2013 14:52:57 +0100
Message-ID: <529F33B9.6010208@cybertec.at> (raw)
In-Reply-To: <529751FB.40107@cybertec.at>
References: <4F95613B.2030904@cybertec.at>
	<20120424081714.GA12034@feivel.credativ.lan>
	<520F4B90.2010800@cybertec.at>
	<5226EA00.6040202@cybertec.at>
	<1378517102.7389.2.camel@vanquo.pezone.net>
	<522B7130.8040006@cybertec.at>
	<1378775047.14736.0.camel@vanquo.pezone.net>
	<522EA559.4090105@cybertec.at>
	<20131010221648.GK4825@eldon.alvh.no-ip.org>
	<5280A0C2.2030007@cybertec.at>
	<20131112060158.GA818667@tornado.leadboat.com>
	<5281C792.3040809@cybertec.at>
	<528CBC10.9080203@cybertec.at>
	<528CC655.2070309@cybertec.at>
	<529751FB.40107@cybertec.at>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

2013-11-28 15:23 keltezéssel, Boszormenyi Zoltan írta:
> Rebased after killing the patch that changed the DECLARE CURSOR command tag.
> The ECPG readahead patch and all the small following patches are attached.

Fixed the extra spaces that "git apply" complains about.

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

-- 
----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de
      http://www.postgresql.at/

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachments:

  [application/x-tar] 26.patch.gz (41.3K, ../529F33B9.6010208@cybertec.at/2-26.patch.gz)
  download

  [application/x-tar] 27.patch.gz (5.6K, ../529F33B9.6010208@cybertec.at/3-27.patch.gz)
  download

  [application/x-tar] 28.patch.gz (6.3K, ../529F33B9.6010208@cybertec.at/4-28.patch.gz)
  download

  [application/x-tar] 29.patch.gz (3.4K, ../529F33B9.6010208@cybertec.at/5-29.patch.gz)
  download

  [text/x-patch] 30.patch (1.6K, ../529F33B9.6010208@cybertec.at/6-30.patch)
  download | inline diff:
commit 29425979f229ae99fe32b8540d65919e517b1c33
Author: Böszörményi Zoltán <zb@cybertec.at>
Date:   Wed Dec 4 14:27:29 2013 +0100

    ECPG: During FETCH ALL, temporarily use FETCHALL_MULTIPLIER times
    the current readahead window size. FETCHALL_MULTIPLIER == 1000.
    No change in regression tests.

diff --git a/src/interfaces/ecpg/ecpglib/cursor.c b/src/interfaces/ecpg/ecpglib/cursor.c
index 1c24133..2d024b8 100644
--- a/src/interfaces/ecpg/ecpglib/cursor.c
+++ b/src/interfaces/ecpg/ecpglib/cursor.c
@@ -1518,6 +1518,7 @@ ecpg_cursor_fetch(struct statement *stmt, struct cursor_descriptor *cur,
 	long		ntuples;
 	int		step;
 	int64		prev_pos, next_pos, start_idx, var_index;
+	int64		old_readahead;
 
 	switch (direction)
 	{
@@ -1689,6 +1690,10 @@ abs_rel:
 			goto abs_rel;
 		}
 
+		old_readahead = cur->readahead;
+		if (fetchall)
+			cur->readahead *= FETCHALL_MULTIPLIER;
+
 		/*
 		 * The direction is backward if FETCH BACKWARD ALL
 		 * or the amount to fetch is negative.
@@ -1772,6 +1777,8 @@ abs_rel:
 
 		sqlca->sqlerrd[2] = (var_index <= LONG_MAX ? var_index : 0);
 
+		cur->readahead = old_readahead;
+
 		if (var_index == 0)
 		{
 			ecpg_raise(stmt->lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL);
diff --git a/src/interfaces/ecpg/ecpglib/extern.h b/src/interfaces/ecpg/ecpglib/extern.h
index 612412f..de0f3b8 100644
--- a/src/interfaces/ecpg/ecpglib/extern.h
+++ b/src/interfaces/ecpg/ecpglib/extern.h
@@ -32,6 +32,7 @@ enum ARRAY_TYPE
 #define LOOP_FORWARD	(1)
 #define LOOP_BACKWARD	(-1)
 #define MAX_CACHE_MISS	(3)
+#define FETCHALL_MULTIPLIER	(1000)
 
 /* A generic varchar type. */
 struct ECPGgeneric_varchar

  [application/x-tar] 31.patch.gz (6.3K, ../529F33B9.6010208@cybertec.at/7-31.patch.gz)
  download

view thread (8+ messages)  latest in thread

Message-ID: <529F33B9.6010208@cybertec.at>
Permalink:  ../529F33B9.6010208@cybertec.at/
Also on:    postgresql.org/message-id/529F33B9.6010208@cybertec.at

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: zb@cybertec.at, alvherre@2ndquadrant.com, meskes@postgresql.org, noah@leadboat.com, peter_e@gmx.net, robertmhaas@gmail.com, hlinnakangas@vmware.com, bruce@momjian.us, hs@cybertec.at
  Subject: Re: ECPG FETCH readahead, was: Re: ECPG fixes
  In-Reply-To: <529F33B9.6010208@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox