summaryrefslogtreecommitdiff
path: root/src/backend/optimizer/util
Commit message (Collapse)AuthorAgeFilesLines
* Fix relative path references so that make knowns which dependencies referPeter Eisentraut2000-08-311-6/+4
| | | | | to one another. Sort out builddir vs srcdir variable namings. Remove some now obsoleted make variables.
* SQL-language functions are now callable in ordinary fmgr contexts ...Tom Lane2000-08-241-4/+2
| | | | | | for example, an SQL function can be used in a functional index. (I make no promises about speed, but it'll work ;-).) Clean up and simplify handling of functions returning sets.
* fmgr interface mopup work. Use new DatumGetBool and BoolGetDatumTom Lane2000-08-211-17/+23
| | | | | | | | macros where appropriate (the code used to have several different ways of doing that, including Int32, Int8, UInt8, ...). Remove last few references to float32 and float64 typedefs --- it's all float4/float8 now. The typedefs themselves should probably stay in c.h for a release or two, though, to avoid breaking user-written C functions.
* Clean up handling of variable-free qual clauses. System now does theTom Lane2000-08-131-18/+138
| | | | | | | | | | right thing with variable-free clauses that contain noncachable functions, such as 'WHERE random() < 0.5' --- these are evaluated once per potential output tuple. Expressions that contain only Params are now candidates to be indexscan quals --- for example, 'var = ($1 + 1)' can now be indexed. Cope with RelabelType nodes atop potential indexscan variables --- this oversight prevents 7.0.* from recognizing some potentially indexscanable situations.
* Remove 'func_tlist' from Func expression nodes, likewise 'param_tlist'Tom Lane2000-08-082-9/+15
| | | | | | | | from Param nodes, per discussion a few days ago on pghackers. Add new expression node type FieldSelect that implements the functionality where it's actually needed. Clean up some other unused fields in Func nodes as well. NOTE: initdb forced due to change in stored expression trees for rules.
* Make planner safe for recursive calls --- needed for cases whereTom Lane2000-07-271-51/+7
| | | | eval_const_expressions tries to simplify an SQL function.
* First stage of reclaiming memory in executor by resetting short-termTom Lane2000-07-121-8/+22
| | | | | | memory contexts. Currently, only leaks in expressions executed as quals or projections are handled. Clean up some old dead cruft in executor while at it --- unused fields in state nodes, that sort of thing.
* Update textin() and textout() to new fmgr style. This is just phaseTom Lane2000-07-051-2/+4
| | | | | one of updating the whole text datatype, but there are so dang many calls of these two routines that it seems worth a separate commit.
* Make inheritance planning logic a little simpler and clearer,Tom Lane2000-06-201-8/+22
| | | | hopefully even a little faster.
* Reimplement nodeMaterial to use a temporary BufFile (or even memory, if theTom Lane2000-06-181-22/+4
| | | | | | | | | | materialized tupleset is small enough) instead of a temporary relation. This was something I was thinking of doing anyway for performance, and Jan says he needs it for TOAST because he doesn't want to cope with toasting noname relations. With this change, the 'noname table' support in heap.c is dead code, and I have accordingly removed it. Also clean up 'noname' plan handling in planner --- nonames are either sort or materialize plans, and it seems less confusing to handle them separately under those names.
* Fix performance problems with pg_index lookups (see, for example,Tom Lane2000-06-171-26/+34
| | | | | | | | | | discussion of 5/19/00). pg_index is now searched for indexes of a relation using an indexscan. Moreover, this is done once and cached in the relcache entry for the relation, in the form of a list of OIDs for the indexes. This list is used by the parser and executor to drive lookups in the pg_index syscache when they want to know the properties of the indexes. Net result: index information will be fully cached for repetitive operations such as inserts.
* Clean up #include's.Bruce Momjian2000-06-151-2/+3
|
* Cause inheritance patch to meet minimum coding standards (no gccTom Lane2000-06-091-8/+13
| | | | warnings).
* Inheritance overhaul by Chris Bitmead <chris@bitmead.com>Bruce Momjian2000-06-091-1/+24
|
* Mark functions as static and ifdef NOT_USED as appropriate.Bruce Momjian2000-06-082-4/+9
|
* Third round of fmgr updates: eliminate calls using fmgr() andTom Lane2000-05-301-33/+27
| | | | | fmgr_faddr() in favor of new-style calls. Lots of cleanup of sloppy casts to use XXXGetDatum and DatumGetXXX ...
* Remove unused include files. Do not touch /port or includes used by defines.Bruce Momjian2000-05-305-16/+5
|
* Generated header files parse.h and fmgroids.h are now copied intoTom Lane2000-05-291-3/+1
| | | | | the src/include tree, so that -I backend is no longer necessary anywhere. Also, clean up some bit rot in contrib tree.
* Constant-expression simplifier now knows how to simplify strict functionsTom Lane2000-05-281-13/+47
| | | | | that have at least one constant-NULL input, even if other inputs are not constants.
* First round of changes for new fmgr interface. fmgr itself and theTom Lane2000-05-281-2/+4
| | | | | | | key call sites are changed, but most called functions are still oldstyle. An exception is that the PL managers are updated (so, for example, NULL handling now behaves as expected in plperl and plpgsql functions). NOTE initdb is forced due to added column in pg_proc.
* get_relattval() should treat a NULL constant as a non-constant expression,Tom Lane2000-04-161-2/+3
| | | | | | since it has no way to indicate to its caller that the constant is actually NULL. This prevents coredump in cases like WHERE textfield < null::text;
* Ye-old pgindent run. Same 4-space tabs.Bruce Momjian2000-04-126-328/+412
|
* Fix extremely nasty little bug observed when a sub-SELECT appears inTom Lane2000-04-041-33/+103
| | | | | | | | | | | | | | | | | | | | WHERE in a place where it can be part of a nestloop inner indexqual. As the code stood, it put the same physical sub-Plan node into both indxqual and indxqualorig of the IndexScan plan node. That confused later processing in the optimizer (which expected that tracing the subPlan list would visit each subplan node exactly once), and would probably have blown up in the executor if the planner hadn't choked first. Fix by making the 'fixed' indexqual be a complete deep copy of the original indexqual, rather than trying to share nodes below the topmost operator node. This had further ramifications though, because we were making the aforesaid list of sub-Plan nodes during SS_process_sublinks which is run before construction of the 'fixed' indexqual, meaning that the copy of the sub-Plan didn't show up in that list. Fix by rearranging logic so that the sub-Plan list is built by the final set_plan_references pass, not in SS_process_sublinks. This may sound like a mess, but it's actually a good deal cleaner now than it was before, because we are no longer dependent on the assumption that planning will never make a copy of a sub-Plan node.
* Repair logic flaw in cost estimator: cost_nestloop() was estimating CPUTom Lane2000-03-221-3/+10
| | | | | | | | | | | | | costs using the inner path's parent->rows count as the number of tuples processed per inner scan iteration. This is wrong when we are using an inner indexscan with indexquals based on join clauses, because the rows count in a Relation node reflects the selectivity of the restriction clauses for that rel only. Upshot was that if join clause was very selective, we'd drastically overestimate the true cost of the join. Fix is to calculate correct output-rows estimate for an inner indexscan when the IndexPath node is created and save it in the path node. Change of path node doesn't require initdb, since path nodes don't appear in saved rules.
* Restructure planning code so that preprocessing of targetlist and qualsTom Lane2000-03-211-24/+13
| | | | | | | | | | | | | to simplify constant expressions and expand SubLink nodes into SubPlans is done in a separate routine subquery_planner() that calls union_planner(). We formerly did most of this work in query_planner(), but that's the wrong place because it may never see the real targetlist. Splitting union_planner into two routines also allows us to avoid redundant work when union_planner is invoked recursively for UNION and inheritance cases. Upshot is that it is now possible to do something like select float8(count(*)) / (select count(*) from int4_tbl) from int4_tbl group by f1; which has never worked before.
* Minor code rearrangement & doc improvement in eval_const_expressions().Tom Lane2000-03-191-105/+129
|
* Fix performance bug in constant-expression simplifier. After findingTom Lane2000-03-121-5/+13
| | | | | | | | | that the inputs to a given operator can be recursively simplified to constants, it was evaluating the operator using the op's *original* (unsimplified) arg list, so that any subexpressions had to be evaluated again. A constant subexpression at depth N got evaluated N times. Probably not very important in practical situations, but it made us look real slow in MySQL's 'crashme' test...
* Create a new expression node type RelabelType, which exists solely toTom Lane2000-02-201-1/+44
| | | | | | | | | | represent the result of a binary-compatible type coercion. At runtime it just evaluates its argument --- but during type resolution, exprType will pick up the output type of the RelabelType node instead of the type of the argument. This solves some longstanding problems with dropped type coercions, an example being 'select now()::abstime::int4' which used to produce date-formatted output, not an integer, because the coercion to int4 was dropped on the floor.
* Plug some more memory leaks in the planner. It still leaks like a sieve,Tom Lane2000-02-182-7/+6
| | | | but this is as good as it'll get for this release...
* Implement reindex commandHiroshi Inoue2000-02-181-2/+7
|
* Finish repairing 6.5's problems with r-tree indexes: create appropriateTom Lane2000-02-171-18/+19
| | | | | | | | | | | | selectivity functions and make the r-tree operators use them. The estimation functions themselves are just stubs, unfortunately, but perhaps someday someone will make them compute realistic estimates. Change pg_am so that the optimizer can reliably tell the difference between ordered and unordered indexes --- before it would think that an r-tree index can be scanned in '<<' order, which is not right AFAIK. Repair broken negator links for network_sup and related ops. Initdb forced. This might be my last initdb force for 7.0 ... hope so anyway ...
* New cost model for planning, incorporating a penalty for random pageTom Lane2000-02-153-82/+196
| | | | | | | | | | | | | | | | | | | | | | | | | accesses versus sequential accesses, a (very crude) estimate of the effects of caching on random page accesses, and cost to evaluate WHERE- clause expressions. Export critical parameters for this model as SET variables. Also, create SET variables for the planner's enable flags (enable_seqscan, enable_indexscan, etc) so that these can be controlled more conveniently than via PGOPTIONS. Planner now estimates both startup cost (cost before retrieving first tuple) and total cost of each path, so it can optimize queries with LIMIT on a reasonable basis by interpolating between these costs. Same facility is a win for EXISTS(...) subqueries and some other cases. Redesign pathkey representation to achieve a major speedup in planning (I saw as much as 5X on a 10-way join); also minor changes in planner to reduce memory consumption by recycling discarded Path nodes and not constructing unnecessary lists. Minor cleanups to display more-plausible costs in some cases in EXPLAIN output. Initdb forced by change in interface to index cost estimation functions.
* Carry column aliases from the parser frontend. Enables queries likeThomas G. Lockhart2000-02-151-2/+2
| | | | | | | SELECT a FROM t1 tx (a); Allow join syntax, including queries like SELECT * FROM t1 NATURAL JOIN t2; Update RTE structure to hold column aliases in an Attr structure.
* Repair planning bugs caused by my misguided removal of restrictinfo linkTom Lane2000-02-072-137/+448
| | | | | | | | | | | fields in JoinPaths --- turns out that we do need that after all :-(. Also, rearrange planner so that only one RelOptInfo is created for a particular set of joined base relations, no matter how many different subsets of relations it can be created from. This saves memory and processing time compared to the old method of making a bunch of RelOptInfos and then removing the duplicates. Clean up the jointree iteration logic; not sure if it's better, but I sure find it more readable and plausible now, particularly for the case of 'bushy plans'.
* Rename same() to sameseti() to have a slightly less generic name. MoveTom Lane2000-02-062-13/+9
| | | | | | nonoverlap_sets() and is_subset() to list.c, where they should have lived to begin with, and rename to nonoverlap_setsi and is_subseti since they only work on integer lists.
* Redesign DISTINCT ON as discussed in pgsql-sql 1/25/00: syntax is nowTom Lane2000-01-271-7/+24
| | | | | | | | | | | | | SELECT DISTINCT ON (expr [, expr ...]) targetlist ... and there is a check to make sure that the user didn't specify an ORDER BY that's incompatible with the DISTINCT operation. Reimplement nodeUnique and nodeGroup to use the proper datatype-specific equality function for each column being compared --- they used to do bitwise comparisons or convert the data to text strings and strcmp(). (To add insult to injury, they'd look up the conversion functions once for each tuple...) Parse/plan representation of DISTINCT is now a list of SortClause nodes. initdb forced by querytree change...
* Add:Bruce Momjian2000-01-269-18/+27
| | | | | | * Portions Copyright (c) 1996-2000, PostgreSQL, Inc to all files copyright Regents of Berkeley. Man, that's a lot of files.
* Revise handling of index-type-specific indexscan cost estimation, perTom Lane2000-01-222-260/+13
| | | | | | pghackers discussion of 5-Jan-2000. The amopselect and amopnpages estimators are gone, and in their place is a per-AM amcostestimate procedure (linked to from pg_am, not pg_amop).
* Fixed all elog related warnings, as well as a few others.Peter Eisentraut2000-01-151-3/+3
|
* Put back erroneously removed zeroing of sentinel elementsTom Lane2000-01-121-1/+3
| | | | in indexkeys, classlist arrays.
* More cleanups. Still doesn't work.Bruce Momjian2000-01-111-3/+1
|
* Another round of planner/optimizer work. This is just restructuring andTom Lane2000-01-093-379/+235
| | | | | code cleanup; no major improvements yet. However, EXPLAIN does produce more intuitive outputs for nested loops with indexscans now...
* New LDOUT makefile variable for QNX os.Bruce Momjian1999-12-131-2/+2
|
* aggregate(DISTINCT ...) works, per SQL spec.Tom Lane1999-12-131-3/+35
| | | | Note this forces initdb because of change of Aggref node in stored rules.
* Make LD -r as macros that can be changed for QNX.Bruce Momjian1999-12-091-2/+2
|
* Replace generic 'Illegal use of aggregates' error message with one thatTom Lane1999-12-091-13/+47
| | | | | shows the specific ungrouped variable being complained of. Perhaps this will reduce user confusion...
* Tid access method feature from Hiroshi Inoue, Inoue@tpf.co.jpBruce Momjian1999-11-231-1/+27
|
* Add system indexes to match all caches.Bruce Momjian1999-11-222-4/+4
| | | | | | | Make all system indexes unique. Make all cache loads use system indexes. Rename *rel to *relid in inheritance tables. Rename cache names to be clearer.
* Combine index_info and find_secondary_indexes into a single routine thatTom Lane1999-11-212-187/+109
| | | | | | | | | returns a list of RelOptInfos, eliminating the need for static state in index_info. That static state was a direct cause of coredumps; if anything decided to elog(ERROR) partway through an index_info search of pg_index, the next query would try to close a scan pointer that was pointing at no-longer-valid memory. Another example of the reasons to avoid static state variables...
* Fix planner and rewriter to follow SQL semantics for tables that areTom Lane1999-10-071-13/+26
| | | | | | | | | | | mentioned in FROM but not elsewhere in the query: such tables should be joined over anyway. Aside from being more standards-compliant, this allows removal of some very ugly hacks for COUNT(*) processing. Also, allow HAVING clause without aggregate functions, since SQL does. Clean up CREATE RULE statement-list syntax the same way Bruce just fixed the main stmtmulti production. CAUTION: addition of a field to RangeTblEntry nodes breaks stored rules; you will have to initdb if you have any rules.