Index: doc/src/sgml/config.sgml =================================================================== --- doc/src/sgml/config.sgml (revision 30152) +++ doc/src/sgml/config.sgml (working copy) @@ -2281,6 +2281,20 @@ + + cursor_tuple_fraction (floating point) + + cursor_tuple_fraction configuration parameter + + + + Sets the planner's estimate of how many rows of a cursor will + be retrieved by fetches. This affects the planner's favor to + use fast-start plans for cursor. The default is 0.1. + + + + Index: src/backend/optimizer/plan/planner.c =================================================================== --- src/backend/optimizer/plan/planner.c (revision 30152) +++ src/backend/optimizer/plan/planner.c (working copy) @@ -42,6 +42,9 @@ #include "utils/syscache.h" +/* GUC parameter cursor_tuple_fraction */ +double cursor_tuple_fraction = DEFAULT_CURSOR_TUPLE_FRACTION; + /* Hook for plugins to get control in planner() */ planner_hook_type planner_hook = NULL; @@ -143,10 +146,9 @@ /* * We have no real idea how many tuples the user will ultimately FETCH * from a cursor, but it seems a good bet that he doesn't want 'em - * all. Optimize for 10% retrieval (you gotta better number? Should - * this be a SETtable parameter?) + * all. Optimize for 10% retrieval per default. Is a GUC parameter. */ - tuple_fraction = 0.10; + tuple_fraction = cursor_tuple_fraction; } else { Index: src/backend/utils/misc/guc.c =================================================================== --- src/backend/utils/misc/guc.c (revision 30152) +++ src/backend/utils/misc/guc.c (working copy) @@ -1884,6 +1884,15 @@ 0.5, 0.0, 1.0, NULL, NULL }, + { + {"cursor_tuple_fraction", PGC_USERSET, QUERY_TUNING_OTHER, + gettext_noop("Sets the tuple fraction for cursors."), + NULL + }, + &cursor_tuple_fraction, + DEFAULT_CURSOR_TUPLE_FRACTION, 0.0, 1.0, NULL, NULL + }, + /* End-of-list marker */ { {NULL, 0, 0, NULL, NULL}, NULL, 0.0, 0.0, 0.0, NULL, NULL Index: src/backend/utils/misc/postgresql.conf.sample =================================================================== --- src/backend/utils/misc/postgresql.conf.sample (revision 30152) +++ src/backend/utils/misc/postgresql.conf.sample (working copy) @@ -223,6 +223,7 @@ #from_collapse_limit = 8 #join_collapse_limit = 8 # 1 disables collapsing of explicit # JOIN clauses +#cursor_tuple_fraction = 0.1 # range 0.0-1.0 #------------------------------------------------------------------------------ Index: src/include/optimizer/planmain.h =================================================================== --- src/include/optimizer/planmain.h (revision 30152) +++ src/include/optimizer/planmain.h (working copy) @@ -18,6 +18,12 @@ #include "nodes/relation.h" /* + * GUC parameter cursor_tuple_fraction + */ +#define DEFAULT_CURSOR_TUPLE_FRACTION 0.1 +extern double cursor_tuple_fraction; + +/* * prototypes for plan/planmain.c */ extern void query_planner(PlannerInfo *root, List *tlist,