aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/path/indxpath.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-02-14 19:37:30 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2019-02-14 19:37:30 -0500
commit8fd3fdd85a3e22f04b2cb0949450f63cb48952cd (patch)
tree1b3468699da2df4730637f972a7eb94e2546acce /src/backend/optimizer/path/indxpath.c
parent86eea78694ce0d95e74cc82cc29c096d66a9accd (diff)
downloadpostgresql-8fd3fdd85a3e22f04b2cb0949450f63cb48952cd.tar.gz
postgresql-8fd3fdd85a3e22f04b2cb0949450f63cb48952cd.zip
Simplify the planner's new representation of indexable clauses a little.
In commit 1a8d5afb0, I thought it'd be a good idea to define IndexClause.indexquals as NIL in the most common case where the given clause (IndexClause.rinfo) is usable exactly as-is. It'd be more consistent to define the indexquals in that case as being a one-element list containing IndexClause.rinfo, but I thought saving the palloc overhead for making such a list would be worthwhile. In hindsight, that was a great example of "premature optimization is the root of all evil": it's complicated everyplace that needs to deal with the indexquals, requiring duplicative code to handle both the simple case and the not-simple case. I'd initially found that tolerable but it's getting less so as I mop up some areas that I'd not touched in 1a8d5afb0. In any case, two more pallocs during a planner run are surely at the noise level (a conclusion confirmed by a bit of microbenchmarking). So let's change this decision before it becomes set in stone, and insist that IndexClause.indexquals always be a valid list of the actual index quals for the clause. Discussion: https://postgr.es/m/24586.1550106354@sss.pgh.pa.us
Diffstat (limited to 'src/backend/optimizer/path/indxpath.c')
-rw-r--r--src/backend/optimizer/path/indxpath.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c
index e0933fc24d0..3434219dbd1 100644
--- a/src/backend/optimizer/path/indxpath.c
+++ b/src/backend/optimizer/path/indxpath.c
@@ -2435,7 +2435,7 @@ match_clause_to_indexcol(PlannerInfo *root,
{
iclause = makeNode(IndexClause);
iclause->rinfo = rinfo;
- iclause->indexquals = NIL;
+ iclause->indexquals = list_make1(rinfo);
iclause->lossy = false;
iclause->indexcol = indexcol;
iclause->indexcols = NIL;
@@ -2599,7 +2599,7 @@ match_opclause_to_indexcol(PlannerInfo *root,
{
iclause = makeNode(IndexClause);
iclause->rinfo = rinfo;
- iclause->indexquals = NIL;
+ iclause->indexquals = list_make1(rinfo);
iclause->lossy = false;
iclause->indexcol = indexcol;
iclause->indexcols = NIL;
@@ -2819,7 +2819,7 @@ match_saopclause_to_indexcol(RestrictInfo *rinfo,
IndexClause *iclause = makeNode(IndexClause);
iclause->rinfo = rinfo;
- iclause->indexquals = NIL;
+ iclause->indexquals = list_make1(rinfo);
iclause->lossy = false;
iclause->indexcol = indexcol;
iclause->indexcols = NIL;
@@ -3078,7 +3078,7 @@ expand_indexqual_rowcompare(RestrictInfo *rinfo,
* usable as index quals.
*/
if (var_on_left && !iclause->lossy)
- iclause->indexquals = NIL;
+ iclause->indexquals = list_make1(rinfo);
else
{
/*