aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/plan/createplan.c
Commit message (Collapse)AuthorAge
...
* Instead of rechecking lossy index operators by putting them into theTom Lane2004-01-06
| | | | | | | | | regular qpqual ('filter condition'), add special-purpose code to nodeIndexscan.c to recheck them. This ends being almost no net addition of code, because the removal of planner code balances out the extra executor code, but it is significantly more efficient when a lossy operator is involved in an OR indexscan. The old implementation had to recheck the entire indexqual in such cases.
* Adjust indexscan planning logic to keep RestrictInfo nodes associatedTom Lane2004-01-05
| | | | | | | | | | | with index qual clauses in the Path representation. This saves a little work during createplan and (probably more importantly) allows reuse of cached selectivity estimates during indexscan planning. Also fix latent bug: wrong plan would have been generated for a 'special operator' used in a nestloop-inner-indexscan join qual, because the special operator would not have gotten into the list of quals to recheck. This bug is only latent because at present the special-operator code could never trigger on a join qual, but sooner or later someone will want to do it.
* Improve UniquePath logic to detect the case where the input is alreadyTom Lane2004-01-05
| | | | | known unique (eg, it is a SELECT DISTINCT ... subquery), and not do a redundant unique-ification step.
* Add the ability to extract OR indexscan conditions from OR-of-ANDTom Lane2004-01-05
| | | | | | | join conditions in which each OR subclause includes a constraint on the same relation. This implements the other useful side-effect of conversion to CNF format, without its unpleasant side-effects. As per pghackers discussion of a few weeks ago.
* $Header: -> $PostgreSQL Changes ...PostgreSQL Daemon2003-11-29
|
* Get rid of hashkeys field of Hash plan node, since it's redundant withTom Lane2003-11-25
| | | | | | the hashclauses field of the parent HashJoin. This avoids problems with duplicated links to SubPlans in hash clauses, as per report from Andrew Holm-Hansen.
* Cross-data-type comparisons are now indexable by btrees, pursuant to myTom Lane2003-11-12
| | | | | | | | | | pghackers proposal of 8-Nov. All the existing cross-type comparison operators (int2/int4/int8 and float4/float8) have appropriate support. The original proposal of storing the right-hand-side datatype as part of the primary key for pg_amop and pg_amproc got modified a bit in the event; it is easier to store zero as the 'default' case and only store a nonzero when the operator is actually cross-type. Along the way, remove the long-since-defunct bigbox_ops operator class.
* Add operator strategy and comparison-value datatype fields to ScanKey.Tom Lane2003-11-09
| | | | | | | | | | | Remove the 'strategy map' code, which was a large amount of mechanism that no longer had any use except reverse-mapping from procedure OID to strategy number. Passing the strategy number to the index AM in the first place is simpler and faster. This is a preliminary step in planned support for cross-datatype index operations. I'm committing it now since the ScanKeyEntryInitialize() API change touches quite a lot of files, and I want to commit those changes before the tree drifts under me.
* Department of second thoughts: can't reorder merge-join clauses.Tom Lane2003-08-27
|
* Push subplan clauses to the back in qual lists for join plans, notTom Lane2003-08-26
| | | | only scan plans. Per observation from Rod Taylor.
* Create a 'type cache' that keeps track of the data needed for any particularTom Lane2003-08-17
| | | | | | | | | | | datatype by array_eq and array_cmp; use this to solve problems with memory leaks in array indexing support. The parser's equality_oper and ordering_oper routines also use the cache. Change the operator search algorithms to look for appropriate btree or hash index opclasses, instead of assuming operators named '<' or '=' have the right semantics. (ORDER BY ASC/DESC now also look at opclasses, instead of assuming '<' and '>' are the right things.) Add several more index opclasses so that there is no regression in functionality for base datatypes. initdb forced due to catalog additions.
* Code cleanup inspired by recent resname bug report (doesn't fix the bugTom Lane2003-08-11
| | | | | | | | yet, though). Avoid using nth() to fetch tlist entries; provide a common routine get_tle_by_resno() to search a tlist for a particular resno. This replaces a couple uses of nth() and a dozen hand-coded search loops. Also, replace a few uses of nth(length-1, list) with llast().
* Another pgindent run with updated typedefs.Bruce Momjian2003-08-08
|
* create_unique_plan() should not discard existing output columns of theTom Lane2003-08-07
| | | | | | subplan it starts with, as they may be needed at upper join levels. See comments added to code for the non-obvious reason why. Per bug report from Robert Creager.
* Update copyrights to 2003.Bruce Momjian2003-08-04
|
* pgindent run.Bruce Momjian2003-08-04
|
* Error message editing in backend/optimizer, backend/rewrite.Tom Lane2003-07-25
|
* Make cost estimates for SubqueryScan more realistic: charge cpu_tuple_costTom Lane2003-07-14
| | | | | for each row processed, and don't forget the evaluation cost of any restriction clauses attached to the node. Per discussion with Greg Stark.
* Restructure building of join relation targetlists so that a join planTom Lane2003-06-29
| | | | | | | | | | | | | | node emits only those vars that are actually needed above it in the plan tree. (There were comments in the code suggesting that this was done at some point in the dim past, but for a long time we have just made join nodes emit everything that either input emitted.) Aside from being marginally more efficient, this fixes the problem noted by Peter Eisentraut where a join above an IN-implemented-as-join might fail, because the subplan targetlist constructed in the latter case didn't meet the expectation of including everything. Along the way, fix some places that were O(N^2) in the targetlist length. This is not all the trouble spots for wide queries by any means, but it's a step forward.
* Allow GROUP BY, ORDER BY, DISTINCT targets to be unknown literals,Tom Lane2003-06-16
| | | | | | | | | silently resolving them to type TEXT. This is comparable to what we do when faced with UNKNOWN in CASE, UNION, and other contexts. It gets rid of this and related annoyances: select distinct f1, '' from int4_tbl; ERROR: Unable to identify an ordering operator '<' for type unknown This was discussed many moons ago, but no one got round to fixing it.
* Adjust nestloop-with-inner-indexscan plan generation so that we catchTom Lane2003-06-15
| | | | | | | some cases of redundant clauses that were formerly not caught. We have to special-case this because the clauses involved never get attached to the same join restrictlist and so the existing logic does not notice that they are redundant.
* Knock down a couple more lappend() hotspots for large WHERE clauses.Tom Lane2003-05-28
|
* Replace functional-index facility with expressional indexes. Any columnTom Lane2003-05-28
| | | | | | | | | | | of an index can now be a computed expression instead of a simple variable. Restrictions on expressions are the same as for predicates (only immutable functions, no sub-selects). This fixes problems recently introduced with inlining SQL functions, because the inlining transformation is applied to both expression trees so the planner can still match them up. Along the way, improve efficiency of handling index predicates (both predicates and index expressions are now cached by the relcache) and fix 7.3 oversight that didn't record dependencies of predicate expressions.
* Apply fixes for problems with dropped columns whose types have also beenTom Lane2003-05-12
| | | | | | | | | | | dropped. The simplest fix for INSERT/UPDATE cases turns out to be for preptlist.c to insert NULLs of a known-good type (I used INT4) rather than making them match the deleted column's type. Since the representation of NULL is actually datatype-independent, this should work fine. I also re-reverted the patch to disable the use_physical_tlist optimization in the presence of dropped columns. It still doesn't look worth the trouble to be smarter, if there are no other bugs to fix. Added a regression test to catch future problems in this area.
* Revert previous change --- turns out the underlying problem affectsTom Lane2003-05-11
| | | | | more cases than I thought, so ExecTypeFromTL() will have to be fixed anyway.
* Disable the recently-added use_physical_tlist optimization in casesTom Lane2003-05-11
| | | | | | | | where the table contains dropped columns. If the columns are dropped, then their types may be gone as well, which causes ExecTypeFromTL() to fail if the dropped columns appear in a plan node's tlist. This could be worked around but I don't think the optimization is valuable enough to be worth the trouble.
* Implement feature of new FE/BE protocol whereby RowDescription identifiesTom Lane2003-05-06
| | | | | | | | | the column by table OID and column number, if it's a simple column reference. Along the way, get rid of reskey/reskeyop fields in Resdoms. Turns out that representation was not convenient for either the planner or the executor; we can make the planner deliver exactly what the executor wants with no more effort. initdb forced due to change in stored rule representation.
* Restructure parsetree representation of DECLARE CURSOR: now it's aTom Lane2003-03-10
| | | | | | | | | | | | utility statement (DeclareCursorStmt) with a SELECT query dangling from it, rather than a SELECT query with a few unusual fields in it. Add code to determine whether a planned query can safely be run backwards. If DECLARE CURSOR specifies SCROLL, ensure that the plan can be run backwards by adding a Materialize plan node if it can't. Without SCROLL, you get an error if you try to fetch backwards from a cursor that can't handle it. (There is still some discussion about what the exact behavior should be, but this is necessary infrastructure in any case.) Along the way, make EXPLAIN DECLARE CURSOR work.
* Back off previous patch to skip projection step in scan plan nodes,Tom Lane2003-02-16
| | | | | | | in the case where the node immediately above the scan is a Hash, Sort, or Material node. In these cases it's better to do the projection so that we don't store unneeded columns in the hash/sort/materialize table. Per discussion a few days ago with Anagh Lal.
* Create a distinction between Lists of integers and Lists of OIDs, to getTom Lane2003-02-09
| | | | | | rid of the assumption that sizeof(Oid)==sizeof(int). This is one small step towards someday supporting 8-byte OIDs. For the moment, it doesn't do much except get rid of a lot of unsightly casts.
* Replace planner's representation of relation sets, per pghackers discussion.Tom Lane2003-02-08
| | | | | Instead of Lists of integers, we now store variable-length bitmap sets. This should be faster as well as less error-prone.
* Tweak planner and executor to avoid doing ExecProject() in table scanTom Lane2003-02-03
| | | | | | | | nodes where it's not really necessary. In many cases where the scan node is not the topmost plan node (eg, joins, aggregation), it's possible to just return the table tuple directly instead of generating an intermediate projection tuple. In preliminary testing, this reduced the CPU time needed for 'SELECT COUNT(*) FROM foo' by about 10%.
* Implement choice between hash-based and sort-based grouping for doingTom Lane2003-01-22
| | | | DISTINCT processing on the output of an IN sub-select.
* IN clauses appearing at top level of WHERE can now be handled as joins.Tom Lane2003-01-20
| | | | | | | | | | There are two implementation techniques: the executor understands a new JOIN_IN jointype, which emits at most one matching row per left-hand row, or the result of the IN's sub-select can be fed through a DISTINCT filter and then joined as an ordinary relation. Along the way, some minor code cleanup in the optimizer; notably, break out most of the jointree-rearrangement preprocessing in planner.c and put it in a new file prep/prepjointree.c.
* Now that switch_outer processing no longer relies on being run afterTom Lane2003-01-15
| | | | | | | join_references(), it's practical to consolidate all join_references() processing into the set_plan_references traversal in setrefs.c. This seems considerably cleaner than the old way where we did it for join quals in createplan.c and for targetlists in setrefs.c.
* Allow merge and hash joins to occur on arbitrary expressions (anything notTom Lane2003-01-15
| | | | | | | | | | | | | | | | containing a volatile function), rather than only on 'Var = Var' clauses as before. This makes it practical to do flatten_join_alias_vars at the start of planning, which in turn eliminates a bunch of klugery inside the planner to deal with alias vars. As a free side effect, we now detect implied equality of non-Var expressions; for example in SELECT ... WHERE a.x = b.y and b.y = 42 we will deduce a.x = 42 and use that as a restriction qual on a. Also, we can remove the restriction introduced 12/5/02 to prevent pullup of subqueries whose targetlists contain sublinks. Still TODO: make statistical estimation routines in selfuncs.c and costsize.c smarter about expressions that are more complex than plain Vars. The need for this is considerably greater now that we have to be able to estimate the suitability of merge and hash join techniques on such expressions.
* Cause planner to account for evaluation costs in targetlists andTom Lane2003-01-13
| | | | | | | | HAVING quals. Normally this is an insignificant effect --- but it will not be insignificant when these clauses contain sub-selects. The added costs cannot affect the planning of the query containing them, but they might have an impact when the query is a sub-query of a larger one.
* Phase 2 of read-only-plans project: restructure expression-tree nodesTom Lane2002-12-12
| | | | | | | | | so that all executable expression nodes inherit from a common supertype Expr. This is somewhat of an exercise in code purity rather than any real functional advance, but getting rid of the extra Oper or Func node formerly used in each operator or function call should provide at least a little space and speed improvement. initdb forced by changes in stored-rules representation.
* Phase 1 of read-only-plans project: cause executor state nodes to pointTom Lane2002-12-05
| | | | | | | | | | to plan nodes, not vice-versa. All executor state nodes now inherit from struct PlanState. Copying of plan trees has been simplified by not storing a list of SubPlans in Plan nodes (eliminating duplicate links). The executor still needs such a list, but it can build it during ExecutorStart since it has to scan the plan tree anyway. No initdb forced since no stored-on-disk structures changed, but you will need a full recompile because of node-numbering changes.
* Be more realistic about plans involving Materialize nodes: take theirTom Lane2002-11-30
| | | | cost into account while planning.
* Upgrade planner and executor to allow multiple hash keys for a hash join,Tom Lane2002-11-30
| | | | | | instead of only one. This should speed up planning (only one hash path to consider for a given pair of relations) as well as allow more effective hashing, when there are multiple hashable joinclauses.
* Finish implementation of hashed aggregation. Add enable_hashagg GUCTom Lane2002-11-21
| | | | | | parameter to allow it to be forced off for comparison purposes. Add ORDER BY clauses to a bunch of regression test queries that will otherwise produce randomly-ordered output in the new regime.
* Add an at-least-marginally-plausible method of estimating the numberTom Lane2002-11-19
| | | | | | of groups produced by GROUP BY. This improves the accuracy of planning estimates for grouped subselects, and is needed to check whether a hashed aggregation plan risks memory overflow.
* Push qual clauses containing subplans to the back of the qual listTom Lane2002-11-15
| | | | at each plan node. Per gripe from Ross Reedstrom.
* Phase 2 of hashed-aggregation project. nodeAgg.c now knows how to doTom Lane2002-11-06
| | | | hashed aggregation, but there's not yet planner support for it.
* First phase of implementing hash-based grouping/aggregation. An AGG planTom Lane2002-11-06
| | | | | | | | | | | | | node now does its own grouping of the input rows, and has no need for a preceding GROUP node in the plan pipeline. This allows elimination of the misnamed tuplePerGroup option for GROUP, and actually saves more code in nodeGroup.c than it costs in nodeAgg.c, as well as being presumably faster. Restructure the API of query_planner so that we do not commit to using a sorted or unsorted plan in query_planner; instead grouping_planner makes the decision. (Right now it isn't any smarter than query_planner was, but that will change as soon as it has the option to select a hash- based aggregation step.) Despite all the hackery, no initdb needed since only in-memory node types changed.
* Extend pg_cast castimplicit column to a three-way value; this allows usTom Lane2002-09-18
| | | | | | | | | | | | | | | | | | | | | | | | to be flexible about assignment casts without introducing ambiguity in operator/function resolution. Introduce a well-defined promotion hierarchy for numeric datatypes (int2->int4->int8->numeric->float4->float8). Change make_const to initially label numeric literals as int4, int8, or numeric (never float8 anymore). Explicitly mark Func and RelabelType nodes to indicate whether they came from a function call, explicit cast, or implicit cast; use this to do reverse-listing more accurately and without so many heuristics. Explicit casts to char, varchar, bit, varbit will truncate or pad without raising an error (the pre-7.2 behavior), while assigning to a column without any explicit cast will still raise an error for wrong-length data like 7.3. This more nearly follows the SQL spec than 7.2 behavior (we should be reporting a 'completion condition' in the explicit-cast cases, but we have no mechanism for that, so just do silent truncation). Fix some problems with enforcement of typmod for array elements; it didn't work at all in 'UPDATE ... SET array[n] = foo', for example. Provide a generalized array_length_coerce() function to replace the specialized per-array-type functions that used to be needed (and were missing for NUMERIC as well as all the datetime types). Add missing conversions int8<->float4, text<->numeric, oid<->int8. initdb forced.
* pgindent run.Bruce Momjian2002-09-04
|
* Remove sys/types.h in files that include postgres.h, and hence c.h,Bruce Momjian2002-09-02
| | | | because c.h has sys/types.h.
* Update copyright to 2002.Bruce Momjian2002-06-20
|