|
134 | 134 | <structfield>amsearchnulls</structfield>, indicating that it supports
|
135 | 135 | <literal>IS NULL</> and <literal>IS NOT NULL</> clauses as search
|
136 | 136 | conditions.
|
137 |
| - An index method can also set <structfield>amcanreturn</structfield>, |
138 |
| - indicating that it can support <firstterm>index-only scans</> by returning |
139 |
| - the indexed column values for an index entry in the form of an IndexTuple. |
140 |
| - (An example of an index AM that cannot do this is hash, which stores only |
141 |
| - the hash values not the original data.) |
142 | 137 | </para>
|
143 | 138 |
|
144 | 139 | </sect1>
|
@@ -278,6 +273,19 @@ amvacuumcleanup (IndexVacuumInfo *info,
|
278 | 273 |
|
279 | 274 | <para>
|
280 | 275 | <programlisting>
|
| 276 | +bool |
| 277 | +amcanreturn (Relation indexRelation); |
| 278 | +</programlisting> |
| 279 | + Check whether the index can support <firstterm>index-only scans</> by |
| 280 | + returning the indexed column values for an index entry in the form of an |
| 281 | + IndexTuple. Return TRUE if so, else FALSE. If the index AM can never |
| 282 | + support index-only scans (an example is hash, which stores only |
| 283 | + the hash values not the original data), it is sufficient to set its |
| 284 | + <structfield>amcanreturn</> field to zero in <structname>pg_am</>. |
| 285 | + </para> |
| 286 | + |
| 287 | + <para> |
| 288 | +<programlisting> |
281 | 289 | void
|
282 | 290 | amcostestimate (PlannerInfo *root,
|
283 | 291 | IndexOptInfo *index,
|
@@ -391,9 +399,9 @@ amgettuple (IndexScanDesc scan,
|
391 | 399 | </para>
|
392 | 400 |
|
393 | 401 | <para>
|
394 |
| - If the access method supports index-only scans (i.e., |
395 |
| - <structfield>amcanreturn</structfield> is TRUE in its <structname>pg_am</> |
396 |
| - row), then on success it must also check |
| 402 | + If the index supports index-only scans (i.e., |
| 403 | + <function>amcanreturn</function> returns TRUE for it), |
| 404 | + then on success the AM must also check |
397 | 405 | <literal>scan->xs_want_itup</>, and if that is true it must return
|
398 | 406 | the original indexed data for the index entry, in the form of an
|
399 | 407 | <structname>IndexTuple</> pointer stored at <literal>scan->xs_itup</>,
|
|
0 commit comments