mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-30 04:57:19 +02:00
per previous discussion on pghackers. Most of the duplicate code in different AMs' ambuild routines has been moved out to a common routine in index.c; this means that all index types now do the right things about inserting recently-dead tuples, etc. (I also removed support for EXTEND INDEX in the ambuild routines, since that's about to go away anyway, and it cluttered the code a lot.) The retail indextuple deletion routines have been replaced by a "bulk delete" routine in which the indexscan is inside the access method. I haven't pushed this change as far as it should go yet, but it should allow considerable simplification of the internal bookkeeping for deletions. Also, add flag columns to pg_am to eliminate various hardcoded tests on AM OIDs, and remove unused pg_am columns. Fix rtree and gist index types to not attempt to store NULLs; before this, gist usually crashed, while rtree managed not to crash but computed wacko bounding boxes for NULL entries (which might have had something to do with the performance problems we've heard about occasionally). Add AtEOXact routines to hash, rtree, and gist, all of which have static state that needs to be reset after an error. We discovered this need long ago for btree, but missed the other guys. Oh, one more thing: concurrent VACUUM is now the default. |
||
---|---|---|
.. | ||
_deadcode | ||
execAmi.c | ||
execFlatten.c | ||
execJunk.c | ||
execMain.c | ||
execProcnode.c | ||
execQual.c | ||
execScan.c | ||
execTuples.c | ||
execUtils.c | ||
functions.c | ||
Makefile | ||
nodeAgg.c | ||
nodeAppend.c | ||
nodeGroup.c | ||
nodeHash.c | ||
nodeHashjoin.c | ||
nodeIndexscan.c | ||
nodeLimit.c | ||
nodeMaterial.c | ||
nodeMergejoin.c | ||
nodeNestloop.c | ||
nodeResult.c | ||
nodeSeqscan.c | ||
nodeSetOp.c | ||
nodeSort.c | ||
nodeSubplan.c | ||
nodeSubqueryscan.c | ||
nodeTidscan.c | ||
nodeUnique.c | ||
README | ||
spi.c |
$Header: /cvsroot/pgsql/src/backend/executor/README,v 1.1 2001/05/15 00:35:50 tgl Exp $ The Postgres Executor --------------------- The executor processes a tree of "plan nodes". The plan tree is essentially a demand-pull pipeline of tuple processing operations. Each node, when called, will produce the next tuple in its output sequence, or NULL if no more tuples are available. If the node is not a primitive relation-scanning node, it will have child node(s) that it calls in turn to obtain input tuples. Refinements on this basic model include: * Choice of scan direction (forwards or backwards). Caution: this is not currently well-supported. It works for primitive scan nodes, but not very well for joins, aggregates, etc. * Rescan command to reset a node and make it generate its output sequence over again. * Parameters that can alter a node's results. After adjusting a parameter, the rescan command must be applied to that node and all nodes above it. There is a moderately intelligent scheme to avoid rescanning nodes unnecessarily (for example, Sort does not rescan its input if no parameters of the input have changed, since it can just reread its stored sorted data). The plan tree concept implements SELECT directly: it is only necessary to deliver the top-level result tuples to the client, or insert them into another table in the case of INSERT ... SELECT. (INSERT ... VALUES is handled similarly, but the plan tree is just a Result node with no source tables.) For UPDATE, the plan tree selects the tuples that need to be updated (WHERE condition) and delivers a new calculated tuple value for each such tuple, plus a "junk" (hidden) tuple CTID identifying the target tuple. The executor's top level then uses this information to update the correct tuple. DELETE is similar to UPDATE except that only a CTID need be delivered by the plan tree. XXX a great deal more documentation needs to be written here... EvalPlanQual (READ COMMITTED update checking) --------------------------------------------- For simple SELECTs, the executor need only pay attention to tuples that are valid according to the snapshot seen by the current transaction (ie, they were inserted by a previously committed transaction, and not deleted by any previously committed transaction). However, for UPDATE and DELETE it is not cool to modify or delete a tuple that's been modified by an open or concurrently-committed transaction. If we are running in SERIALIZABLE isolation level then we just raise an error when this condition is seen to occur. In READ COMMITTED isolation level, we must work a lot harder. The basic idea in READ COMMITTED mode is to take the modified tuple committed by the concurrent transaction (after waiting for it to commit, if need be) and re-evaluate the query qualifications to see if it would still meet the quals. If so, we regenerate the updated tuple (if we are doing an UPDATE) from the modified tuple, and finally update/delete the modified tuple. SELECT FOR UPDATE behaves similarly, except that its action is just to mark the modified tuple for update by the current transaction. To implement this checking, we actually re-run the entire query from scratch for each modified tuple, but with the scan node that sourced the original tuple set to return only the modified tuple, not the original tuple or any of the rest of the relation. If this query returns a tuple, then the modified tuple passes the quals (and the query output is the suitably modified update tuple, if we're doing UPDATE). If no tuple is returned, then the modified tuple fails the quals, so we ignore it and continue the original query. (This is reasonably efficient for simple queries, but may be horribly slow for joins. A better design would be nice; one thought for future investigation is to treat the tuple substitution like a parameter, so that we can avoid rescanning unrelated nodes.) Note a fundamental bogosity of this approach: if the relation containing the original tuple is being used in a self-join, the other instance(s) of the relation will be treated as still containing the original tuple, whereas logical consistency would demand that the modified tuple appear in them too. But we'd have to actually substitute the modified tuple for the original, while still returning all the rest of the relation, to ensure consistent answers. Implementing this correctly is a task for future work. In UPDATE/DELETE, only the target relation needs to be handled this way, so only one special recheck query needs to execute at a time. In SELECT FOR UPDATE, there may be multiple relations flagged FOR UPDATE, so it's possible that while we are executing a recheck query for one modified tuple, we will hit another modified tuple in another relation. In this case we "stack up" recheck queries: a sub-recheck query is spawned in which both the first and second modified tuples will be returned as the only components of their relations. (In event of success, all these modified tuples will be marked for update.) Again, this isn't necessarily quite the right thing ... but in simple cases it works. Potentially, recheck queries could get nested to the depth of the number of FOR UPDATE relations in the query. It should be noted also that UPDATE/DELETE expect at most one tuple to result from the modified query, whereas in the FOR UPDATE case it's possible for multiple tuples to result (since we could be dealing with a join in which multiple tuples join to the modified tuple). We want FOR UPDATE to mark all relevant tuples, so we pass all tuples output by all the stacked recheck queries back to the executor toplevel for marking.