Skip to content

Commit c2f6071

Browse files
committed
Create a FETCH_COUNT parameter that causes psql to execute SELECT-like
queries via a cursor, fetching a limited number of rows at a time and therefore not risking exhausting memory. A disadvantage of the scheme is that 'aligned' output mode will align each group of rows independently leading to odd-looking output, but all the other output formats work reasonably well. Chris Mair, with some additional hacking by moi.
1 parent 7c5ac5c commit c2f6071

File tree

6 files changed

+859
-484
lines changed

6 files changed

+859
-484
lines changed

doc/src/sgml/ref/psql-ref.sgml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.166 2006/07/27 19:52:04 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.167 2006/08/29 22:25:04 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -2007,6 +2007,33 @@ bar
20072007
</listitem>
20082008
</varlistentry>
20092009

2010+
<varlistentry>
2011+
<term><varname>FETCH_COUNT</varname></term>
2012+
<listitem>
2013+
<para>
2014+
If this variable is set to an integer value &gt; 0,
2015+
the results of <command>SELECT</command> queries are fetched
2016+
and displayed in groups of that many rows, rather than the
2017+
default behavior of collecting the entire result set before
2018+
display. Therefore only a
2019+
limited amount of memory is used, regardless of the size of
2020+
the result set. Settings of 100 to 1000 are commonly used
2021+
when enabling this feature.
2022+
Keep in mind that when using this feature, a query may
2023+
fail after having already displayed some rows.
2024+
</para>
2025+
<tip>
2026+
<para>
2027+
Although you can use any output format with this feature,
2028+
the default <literal>aligned</> format tends to look bad
2029+
because each group of <varname>FETCH_COUNT</varname> rows
2030+
will be formatted separately, leading to varying column
2031+
widths across the row groups. The other output formats work better.
2032+
</para>
2033+
</tip>
2034+
</listitem>
2035+
</varlistentry>
2036+
20102037
<varlistentry>
20112038
<term><varname>HISTCONTROL</varname></term>
20122039
<listitem>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy