mirror of
https://github.com/postgres/postgres.git
synced 2025-09-09 13:09:39 +03:00
Support MergeAppend plans, to allow sorted output from append relations.
This patch eliminates the former need to sort the output of an Append scan when an ordered scan of an inheritance tree is wanted. This should be particularly useful for fast-start cases such as queries with LIMIT. Original patch by Greg Stark, with further hacking by Hans-Jurgen Schonig, Robert Haas, and Tom Lane.
This commit is contained in:
@@ -1049,6 +1049,33 @@ typedef struct AppendState
|
||||
int as_whichplan;
|
||||
} AppendState;
|
||||
|
||||
/* ----------------
|
||||
* MergeAppendState information
|
||||
*
|
||||
* nplans how many plans are in the array
|
||||
* nkeys number of sort key columns
|
||||
* scankeys sort keys in ScanKey representation
|
||||
* slots current output tuple of each subplan
|
||||
* heap heap of active tuples (represented as array indexes)
|
||||
* heap_size number of active heap entries
|
||||
* initialized true if we have fetched first tuple from each subplan
|
||||
* last_slot last subplan fetched from (which must be re-called)
|
||||
* ----------------
|
||||
*/
|
||||
typedef struct MergeAppendState
|
||||
{
|
||||
PlanState ps; /* its first field is NodeTag */
|
||||
PlanState **mergeplans; /* array of PlanStates for my inputs */
|
||||
int ms_nplans;
|
||||
int ms_nkeys;
|
||||
ScanKey ms_scankeys; /* array of length ms_nkeys */
|
||||
TupleTableSlot **ms_slots; /* array of length ms_nplans */
|
||||
int *ms_heap; /* array of length ms_nplans */
|
||||
int ms_heap_size; /* current active length of ms_heap[] */
|
||||
bool ms_initialized; /* are subplans started? */
|
||||
int ms_last_slot; /* last subplan slot we returned from */
|
||||
} MergeAppendState;
|
||||
|
||||
/* ----------------
|
||||
* RecursiveUnionState information
|
||||
*
|
||||
|
Reference in New Issue
Block a user