Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit066d246

Browse files
committed
Apply index-only scan patch for parial indexes
1 parentcc8cdd3 commit066d246

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

‎src/backend/optimizer/path/indxpath.c‎

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,13 +1798,13 @@ check_index_only(RelOptInfo *rel, IndexOptInfo *index)
17981798
* Check that all needed attributes of the relation are available from the
17991799
* index.
18001800
*
1801-
*XXX this is overly conservative for partial indexes, since we will
1802-
*consider attributes involved inthe index predicate asrequired even
1803-
* though the predicate won't need to be checked at runtime. (The same is
1804-
* true for attributes used only in index quals, if we are certain that
1805-
* the index is not lossy.)However, it would be quite expensive to
1806-
* determine that accurately at this point, so for now we take the easy
1807-
* way out.
1801+
*For partial indexes we won't consider attributes involved in clauses
1802+
*implied bythe index predicate, asthose won't be needed at runtime.
1803+
*
1804+
*XXX The same istrue for attributes used only in index quals, if we
1805+
*are certain thatthe index is not lossy.However, it would be quite
1806+
*expensive todetermine that accurately at this point, so for now we
1807+
*take the easyway out.
18081808
*/
18091809

18101810
/*
@@ -1819,6 +1819,27 @@ check_index_only(RelOptInfo *rel, IndexOptInfo *index)
18191819
{
18201820
RestrictInfo*rinfo= (RestrictInfo*)lfirst(lc);
18211821

1822+
/*
1823+
* If the index is partial, we won't consider the clauses that are
1824+
* implied by the index predicate (those are not needed at runtime).
1825+
*/
1826+
if (index->indpred!=NIL)
1827+
{
1828+
boolimplied= false;
1829+
List*clauses=NIL;
1830+
1831+
/* need a list for the 'implied_by' call */
1832+
clauses=lappend(clauses, (Node*)rinfo->clause);
1833+
1834+
implied=predicate_implied_by(clauses,index->indpred);
1835+
1836+
/* we generally don't free memory, but well ... */
1837+
list_free(clauses);
1838+
1839+
/* if the clause is implied by index predicate, skip it */
1840+
if (implied)
1841+
continue;
1842+
}
18221843
pull_varattnos((Node*)rinfo->clause,rel->relid,&attrs_used);
18231844
}
18241845

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp