aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/plan/createplan.c
Commit message (Collapse)AuthorAge
...
* Change LIMIT/OFFSET to use int8Bruce Momjian2006-07-26
| | | | Dhanaraj M
* Remove 576 references of include files that were not needed.Bruce Momjian2006-07-14
|
* Sort reference of include files, "A" - "F".Bruce Momjian2006-07-11
|
* Revise the planner's handling of "pseudoconstant" WHERE clauses, that isTom Lane2006-07-01
| | | | | | | | | | | | | | | | | | | clauses containing no variables and no volatile functions. Such a clause can be used as a one-time qual in a gating Result plan node, to suppress plan execution entirely when it is false. Even when the clause is true, putting it in a gating node wins by avoiding repeated evaluation of the clause. In previous PG releases, query_planner() would do this for pseudoconstant clauses appearing at the top level of the jointree, but there was no ability to generate a gating Result deeper in the plan tree. To fix it, get rid of the special case in query_planner(), and instead process pseudoconstant clauses through the normal RestrictInfo qual distribution mechanism. When a pseudoconstant clause is found attached to a path node in create_plan(), pull it out and generate a gating Result at that point. This requires special-casing pseudoconstants in selectivity estimation and cost_qual_eval, but on the whole it's pretty clean. It probably even makes the planner a bit faster than before for the normal case of no pseudoconstants, since removing pull_constant_clauses saves one useless traversal of the qual tree. Per gripe from Phil Frost.
* When a bitmap indexscan is using a partial index, it is necessary to includeTom Lane2006-05-18
| | | | | | | the partial index predicate in the scan's "recheck condition". Otherwise, if the scan becomes lossy for lack of bitmap memory, we would fail to enforce that returned rows satisfy the predicate. Noted while studying bug #2441 from Arjen van der Meijden.
* Improve the representation of FOR UPDATE/FOR SHARE so that we canTom Lane2006-04-30
| | | | | | support both FOR UPDATE and FOR SHARE in one command, as well as both NOWAIT and normal WAIT behavior. The more general code is actually simpler and cleaner.
* The 8.1 planner removes WHERE quals from the plan when the quals areTom Lane2006-04-25
| | | | | | | implied by the predicate of a partial index being used to scan a table. However, this optimization is unsafe in an UPDATE, DELETE, or SELECT FOR UPDATE query, because the quals need to be rechecked by EvalPlanQual if there's an update conflict. Per example from Jean-Samuel Reynaud.
* Update copyright for 2006. Update scripts.Bruce Momjian2006-03-05
|
* When building a bitmap scan, must copy the bitmapqualorig expression treeTom Lane2006-01-29
| | | | | | | | to avoid sharing substructure with the lower-level indexquals. This is currently only an issue if there are SubPlans in the indexquals, which is uncommon but not impossible --- see bug #2218 reported by Nicholas Vinen. We use the same kluge for indexqual vs indexqualorig in the index scans themselves ... would be nice to clean this up someday.
* Allow row comparisons to be used as indexscan qualifications.Tom Lane2006-01-25
| | | | This completes the project to upgrade our handling of row comparisons.
* Teach tid-scan code to make use of "ctid = ANY (array)" clauses, so thatTom Lane2005-11-26
| | | | | | | "ctid IN (list)" will still work after we convert IN to ScalarArrayOpExpr. Make some minor efficiency improvements while at it, such as ensuring that multiple TIDs are fetched in physical heap order. And fix EXPLAIN so that it shows what's really going on for a TID scan.
* Teach planner and executor to handle ScalarArrayOpExpr as an indexableTom Lane2005-11-25
| | | | | | | | | | | qualification when the underlying operator is indexable and useOr is true. That is, indexkey op ANY (ARRAY[...]) is effectively translated into an OR combination of one indexscan for each array element. This only works for bitmap index scans, of course, since regular indexscans no longer support OR'ing of scans. There are still some loose ends to clean up before changing 'x IN (list)' to translate as a ScalarArrayOpExpr; for instance predtest.c ought to be taught about it. But this gets the basic functionality in place.
* Re-run pgindent, fixing a problem where comment lines after a blankBruce Momjian2005-11-22
| | | | | | | | | comment line where output as too long, and update typedefs for /lib directory. Also fix case where identifiers were used as variable names in the backend, but as typedefs in ecpg (favor the backend for indenting). Backpatch to 8.1.X.
* Fix oversight in recent changes to enable the 'physical tlist'Tom Lane2005-10-19
| | | | | | | | | optimization for subquery and function scan nodes: we can't just do it unconditionally, we still have to check whether there is any need for a whole-row Var. I had been thinking that these node types couldn't have any system columns, which is true, but that loop is also checking for attno zero, ie, whole-row Var. Fix comment to not be so misleading. Per test case from Richard Huxton.
* Standard pgindent run for 8.1.Bruce Momjian2005-10-15
|
* Don't try to remove duplicate OR-subclauses in create_bitmap_subplan andTom Lane2005-10-13
| | | | | | | make_restrictinfo_from_bitmapqual. The likelihood of finding duplicates seems much less than in the AND-subclause case, and the cost much higher, because OR lists with hundreds or even thousands of subclauses are not uncommon. Per discussion with Ilia Kantor and andrew@supernews.
* Fix oversight in indexscan plan creation. I recently added code to useTom Lane2005-10-06
| | | | | | | | predicate_implied_by() to detect redundant filter conditions, but forgot that predicate_implied_by() assumes its first argument contains only immutable functions. Add a check to guarantee that. Also, test to see if filter conditions can be discarded because they are redundant with the predicate of a partial index.
* Clean up possibly-uninitialized-variable warnings reported by gcc 4.x.Tom Lane2005-09-24
|
* Fix up LIMIT/OFFSET planning so that we cope with non-constant LIMITTom Lane2005-08-18
| | | | | | | | | | or OFFSET clauses by using estimate_expression_value(). The main advantage of this is that if the expression is a Param and we have a value for the Param, we'll use that value rather than defaulting. Also, fix some thinkos in the logic for combining LIMIT/OFFSET with an externally supplied tuple fraction (this covers cases like EXISTS(...LIMIT...)). And make sure the results of all this are shown by EXPLAIN. Per a gripe from Merlin Moncure.
* Fix a bunch of bad interactions between partial indexes and the newTom Lane2005-07-28
| | | | | | | | planning logic for bitmap indexscans. Partial indexes create corner cases in which a scan might be done with no explicit index qual conditions, and the code wasn't handling those cases nicely. Also be a little tenser about eliminating redundant clauses in the generated plan. Per report from Dmitry Karasik.
* Simple constraint exclusion. For now, only child tables of inheritanceTom Lane2005-07-23
| | | | | scans are candidates for exclusion; this should be fixed eventually. Simon Riggs, with some help from Tom Lane.
* Fix create_unique_plan() so it doesn't generate useless entries in theTom Lane2005-07-15
| | | | | | | | output targetlist of the Unique or HashAgg plan. This code was OK when written, but subsequent changes to use "physical tlists" where possible had broken it: given an input subplan that has extra variables added to avoid a projection step, it would copy those extra variables into the upper tlist, which is pointless since a projection has to happen anyway.
* Teach planner about some cases where a restriction clause can beTom Lane2005-07-02
| | | | | | | | | | | | | | | propagated inside an outer join. In particular, given LEFT JOIN ON (A = B) WHERE A = constant, we cannot conclude that B = constant at the top level (B might be null instead), but we can nonetheless put a restriction B = constant into the quals for B's relation, since no inner-side rows not meeting that condition can contribute to the final result. Similarly, given FULL JOIN USING (J) WHERE J = constant, we can't directly conclude that either input J variable = constant, but it's OK to push such quals into each input rel. Per recent gripe from Kim Bisgaard. Along the way, remove 'valid_everywhere' flag from RestrictInfo, as on closer analysis it was not being used for anything, and was defined backwards anyway.
* Separate predicate-testing code out of indxpath.c, making it a moduleTom Lane2005-06-10
| | | | | in its own right. As proposed by Simon Riggs, but with some editorializing of my own.
* Remove planner's private fields from Query struct, and put them intoTom Lane2005-06-05
| | | | | | | | a new PlannerInfo struct, which is passed around instead of the bare Query in all the planning code. This commit is essentially just a code-beautification exercise, but it does open the door to making larger changes to the planner data structures without having to muck with the widely-known Query struct.
* Add support for FUNCTION RTEs to build_physical_tlist(), so that theTom Lane2005-05-30
| | | | | physical-tlist optimization can be applied to FunctionScan nodes as well as regular tables and SubqueryScans.
* Teach the planner to remove SubqueryScan nodes from the plan if theyTom Lane2005-05-22
| | | | | | | | | aren't doing anything useful (ie, neither selection nor projection). Also, extend to SubqueryScan the hacks already in place to avoid unnecessary ExecProject calls when the result would just be the same tuple the subquery already delivered. This saves some overhead in UNION and other set operations, as well as avoiding overhead for unflatten-able subqueries. Per example from Sokolov Yura.
* Avoid rechecking lossy operators twice in a bitmap scan plan.Tom Lane2005-04-25
|
* While determining the filter clauses for an index scan (either plainTom Lane2005-04-25
| | | | | | or bitmap), use pred_test to be a little smarter about cases where a filter clause is logically unnecessary. This may be overkill for the plain indexscan case, but it's definitely useful for OR'd bitmap scans.
* Replace slightly klugy create_bitmap_restriction() function with aTom Lane2005-04-25
| | | | | more efficient routine in restrictinfo.c (which can make use of make_restrictinfo_internal).
* Remove support for OR'd indexscans internal to a single IndexScan planTom Lane2005-04-25
| | | | | | | | node, as this behavior is now better done as a bitmap OR indexscan. This allows considerable simplification in nodeIndexscan.c itself as well as several planner modules concerned with indexscan plan generation. Also we can improve the sharing of code between regular and bitmap indexscans, since they are now working with nigh-identical Plan nodes.
* Fix bogus EXPLAIN display of rowcount estimates for BitmapAnd andTom Lane2005-04-23
| | | | BitmapOr nodes.
* First cut at planner support for bitmap index scans. Lots to do yet,Tom Lane2005-04-22
| | | | | | | | but the code is basically working. Along the way, rewrite the entire approach to processing OR index conditions, and make it work in join cases for the first time ever. orindxpath.c is now basically obsolete, but I left it in for the time being to allow easy comparison testing against the old implementation.
* Rethink original decision to use AND/OR Expr nodes to represent bitmapTom Lane2005-04-21
| | | | | | | logic operations during planning. Seems cleaner to create two new Path node types, instead --- this avoids duplication of cost-estimation code. Also, create an enable_bitmapscan GUC parameter to control use of bitmap plans.
* Install some slightly realistic cost estimation for bitmap index scans.Tom Lane2005-04-21
|
* Create executor and planner-backend support for decoupled heap and indexTom Lane2005-04-19
| | | | | | | | | scans, using in-memory tuple ID bitmaps as the intermediary. The planner frontend (path creation and cost estimation) is not there yet, so none of this code can be executed. I have tested it using some hacked planner code that is far too ugly to see the light of day, however. Committing now so that the bulk of the infrastructure changes go in before the tree drifts under me.
* Fix oversight in MIN/MAX optimization: must not return NULL entriesTom Lane2005-04-12
| | | | from index, since the aggregates ignore NULLs.
* Merge Resdom nodes into TargetEntry nodes to simplify code and save aTom Lane2005-04-06
| | | | | | | | | few palloc's. I also chose to eliminate the restype and restypmod fields entirely, since they are redundant with information stored in the node's contained expression; re-examining the expression at need seems simpler and more reliable than trying to keep restype/restypmod up to date. initdb forced due to change in contents of stored rules.
* Add a back-link from IndexOptInfo structs to their parent RelOptInfoTom Lane2005-03-27
| | | | | | structs. There are many places in the planner where we were passing both a rel and an index to subroutines, and now need only pass the index struct. Notationally simpler, and perhaps a tad faster.
* Make the behavior of HAVING without GROUP BY conform to the SQL spec.Tom Lane2005-03-10
| | | | | | | | | Formerly, if such a clause contained no aggregate functions we mistakenly treated it as equivalent to WHERE. Per spec it must cause the query to be treated as a grouped query of a single group, the same as appearance of aggregate functions would do. Also, the HAVING filter must execute after aggregate function computation even if it itself contains no aggregate functions.
* Tag appropriate files for rc3PostgreSQL Daemon2004-12-31
| | | | | | | | Also performed an initial run through of upgrading our Copyright date to extend to 2005 ... first run here was very simple ... change everything where: grep 1996-2004 && the word 'Copyright' ... scanned through the generated list with 'less' first, and after, to make sure that I only picked up the right entries ...
* Pgindent run for 8.0.Bruce Momjian2004-08-29
|
* Update copyright to 2004.Bruce Momjian2004-08-29
|
* Desultory de-FastList-ification. RelOptInfo.reltargetlist is back toTom Lane2004-06-01
| | | | being a plain List.
* Use the new List API function names throughout the backend, and disable theNeil Conway2004-05-30
| | | | | list compatibility API by default. While doing this, I decided to keep the llast() macro around and introduce llast_int() and llast_oid() variants.
* Reimplement the linked list data structure used throughout the backend.Neil Conway2004-05-26
| | | | | | | | | | | | | | | | In the past, we used a 'Lispy' linked list implementation: a "list" was merely a pointer to the head node of the list. The problem with that design is that it makes lappend() and length() linear time. This patch fixes that problem (and others) by maintaining a count of the list length and a pointer to the tail node along with each head node pointer. A "list" is now a pointer to a structure containing some meta-data about the list; the head and tail pointers in that structure refer to ListCell structures that maintain the actual linked list of nodes. The function names of the list API have also been changed to, I hope, be more logically consistent. By default, the old function names are still available; they will be disabled-by-default once the rest of the tree has been updated to use the new API names.
* Remove the last traces of Joe Hellerstein's "xfunc" optimization. PatchNeil Conway2004-04-25
| | | | | from Alvaro Herrera. Also, removed lispsort.c, since it is no longer used.
* make_sort_from_pathkeys()'s method for choosing which of severalTom Lane2004-02-29
| | | | | | | | | | equivalent sort expressions to use was broken: you can't just look at the relation membership, you have to actually grovel over the individual Vars in each expression. I think this did work when it was written, but it was broken by subsequent optimizations that made join relations not propagate every single input variable upward. Must find the Var that got propagated, not choose one at random. Per bug report from Daniel O'Neill.
* When testing whether a sub-plan can do projection, use a general-purposeTom Lane2004-01-18
| | | | | | | | | | | | check instead of hardwiring assumptions that only certain plan node types can appear at the places where we are testing. This was always a pretty fragile assumption, and it turns out to be broken in 7.4 for certain cases involving IN-subselect tests that need type coercion. Also, modify code that builds finished Plan tree so that node types that don't do projection always copy their input node's targetlist, rather than having the tlist passed in from the caller. The old method makes it too easy to write broken code that thinks it can modify the tlist when it cannot.
* More janitorial work: remove the explicit casting of NULL literals to aNeil Conway2004-01-07
| | | | | | | | pointer type when it is not necessary to do so. For future reference, casting NULL to a pointer type is only necessary when (a) invoking a function AND either (b) the function has no prototype OR (c) the function is a varargs function.