MCPcopy Create free account
hub / github.com/documentdb/documentdb / LogIndexScanDetails

Function LogIndexScanDetails

pg_documentdb/src/explain/documentdb_explain.c:1035–1080  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1033
1034
1035static void
1036LogIndexScanDetails(pgbson_writer *writer, Oid indexOid, ScanDirection indexorderdir,
1037 List *indexOrderBy, List *indexQuals, IndexScanDescData *scanDesc)
1038{
1039 const char *indexName = ExtensionExplainGetIndexName(indexOid);
1040 if (indexName)
1041 {
1042 PgbsonWriterAppendUtf8(writer, "indexName", -1, indexName);
1043 }
1044
1045 PgbsonWriterAppendUtf8(writer, "direction", -1, ScanDirectionIsBackward(
1046 indexorderdir) ? "Backward" : "Forward");
1047
1048 if (indexOrderBy != NIL)
1049 {
1050 PgbsonWriterAppendBool(writer, "hasOrderBy", -1, true);
1051 }
1052
1053 Oid indexAm = GetIndexAmOid(scanDesc, indexOid);
1054 if (IsBsonRegularIndexAm(indexAm))
1055 {
1056 /* A RUM style index for operators */
1057 Relation index_rel = index_open(indexOid, NoLock);
1058 if (IsCompositeOpClass(index_rel))
1059 {
1060 ExplainRawCompositeScanToWriter(index_rel, indexQuals, indexOrderBy,
1061 indexorderdir,
1062 writer);
1063 }
1064 index_close(index_rel, NoLock);
1065 }
1066
1067 /* TODO: Vector search, geospatial indexes */
1068 pgbson_writer indexQualWriter;
1069 PgbsonWriterStartDocument(writer, "indexFilters", -1, &indexQualWriter);
1070 WriteQuals(&indexQualWriter, indexQuals);
1071 PgbsonWriterEndDocument(writer, &indexQualWriter);
1072
1073 if (indexOrderBy != NIL)
1074 {
1075 pgbson_writer orderWriter;
1076 PgbsonWriterStartDocument(writer, "indexOrderBy", -1, &orderWriter);
1077 WriteIndexOrderBy(&orderWriter, indexOrderBy, indexAm, indexorderdir);
1078 PgbsonWriterEndDocument(writer, &orderWriter);
1079 }
1080}
1081
1082
1083static void

Callers 1

WritePlanStateFunction · 0.85

Calls 11

PgbsonWriterAppendUtf8Function · 0.85
PgbsonWriterAppendBoolFunction · 0.85
GetIndexAmOidFunction · 0.85
IsBsonRegularIndexAmFunction · 0.85
IsCompositeOpClassFunction · 0.85
WriteQualsFunction · 0.85
PgbsonWriterEndDocumentFunction · 0.85
WriteIndexOrderByFunction · 0.85

Tested by

no test coverage detected