Path: redb/redb.Core/Models/RedbIndexPurpose.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Core/Models/RedbIndexPurpose.cs
----
using System;
using System.Collections.Generic;
namespace redb.Core.Models
{
///
/// What an index of the redb schema serves, in a few words, for the index check: an operator who dropped an index on
/// purpose judges from this whether his workload needs it. Named entries first, then the families of the typed value
/// indexes; an index this list does not know gets an empty text.
///
public static class RedbIndexPurpose
{
private static readonly Dictionary Named = new(StringComparer.OrdinalIgnoreCase)
{
// _values
["IX__values__objects"] = "loading the values of an object, deleting an object",
["IX__values__structures"] = "reading or removing every value of one field (scheme changes, migrations)",
["IX__values__array_key"] = "dictionary key filters (Dict[key] == x)",
["IX__values__array_parent_index"] = "collection elements under their parent row, and the cascade when a parent row is deleted",
["IX__values__array_parent_id"] = "collection elements under their parent row, and the cascade when a parent row is deleted",
["IX__values__parent_structure"] = "fields of a class stored in a collection or dictionary (Dict[key].Field)",
["IX__values__structure_parent_batch"] = "batch loading of nested fields by parent row",
["IX__values__object_structure_lookup"] = "conditions on nested and collection fields (EXISTS by object and field)",
["IX__values__object_array_null"] = "reading the scalar fields of a page of objects (covering)",
["IX__values__structure_object_scalar"] = "the streams query form of Pro: a field read for many objects (covering)",
["IX__values__structure_object_lookup"] = "a field read for one object",
["IX__values__structure_object_string"] = "Field == null on a text field",
["IX__values__element_string_object"] = "Contains over an array of strings",
["IX__values__ListItem_not_null"] = "references to list items (deleting a list item)",
["IX__values__Object_not_null"] = "references to objects (deleting a referenced object)",
["UIX__values__structure_object"] = "one value per field and object (integrity)",
["UIX__values__structure_object_parent"] = "one value per field, object and parent row (integrity)",
["UIX__values__structure_object_array_index"] = "one element per position or key (integrity)",
["UIX__values__structure_unique"] = "[RedbUnique] fields (integrity and lookup)",
// _objects
["IX__objects__objects"] = "tree walks: children of an object (parent id)",
["IX__objects__id_parent"] = "tree walks: children of an object (parent id)",
["IX__objects__parent_scheme_id"] = "tree walks restricted to one scheme",
["IX__objects__schemes"] = "queries of one scheme, counting a scheme",
["IX__objects__scheme_id"] = "the streams query form of Pro: the objects of a scheme by id",
["IX__objects__users1"] = "objects by owner",
["IX__objects__users2"] = "objects by last editor",
["IX__objects__date_create"] = "filters and sorts on the creation date",
["IX__objects__date_modify"] = "filters and sorts on the modification date",
["IX__objects__hash"] = "change detection by hash",
["IX__objects__name"] = "filters and sorts on the object name",
["IX__objects__value_datetime"] = "filters on the object's own date value",
["IX__objects__value_guid"] = "filters on the object's own Guid value",
["IX__objects__value_long"] = "filters on the object's own number value",
["IX__objects__value_numeric"] = "filters on the object's own decimal value",
["IX__objects__value_string"] = "filters on the object's own text value",
// metadata and security
["IX__structures__schemes"] = "loading the fields of a scheme",
["IX__structures__structures"] = "nested fields of a field",
["UX__structures__root"] = "one root field per name and scheme (integrity)",
["IX__list_items__id_list"] = "the items of a list",
["IX__list_items__objects"] = "list items that point at an object",
["IX__permissions__ref"] = "permission checks by object",
["IX__permissions__users"] = "permission checks by user",
["IX__users_roles__users"] = "the roles of a user",
};
/// What serves; empty when it is not known here.
public static string Of(string indexName)
{
if (Named.TryGetValue(indexName, out var text))
return text;
// IX__values__structure__object: the value index of one type.
const string prefix = "IX__values__structure_";
const string suffix = "_object";
if (indexName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)
&& indexName.EndsWith(suffix, StringComparison.OrdinalIgnoreCase)
&& indexName.Length > prefix.Length + suffix.Length)
{
var type = indexName.Substring(prefix.Length, indexName.Length - prefix.Length - suffix.Length);
return $"filters, ranges and sorts on {type} fields (value lookups)";
}
return string.Empty;
}
}
}