# Indexes of Table

## Content

## Purpose

A table index is a field-based structure that improves the speed of record lookup operations.
Without indexes, the table must scan all records when performing a search. For large datasets, this can impact performance. By creating indexes on specific fields, the table can locate matching records more efficiently.
Indexes are particularly useful when:

* A field is frequently searched.
* The table contains a large number of records.
* Fast lookup is required for interactive components such as TableSheet.

While indexes improve read performance, they introduce additional maintenance cost. Insert, update, and delete operations may incur slight overhead because indexed fields must be updated accordingly.
Use indexes selectively on fields that are frequently queried.

## Single-Column Indexes

DataManager supports <span class="font-semibold" data-streamdown="strong" style="border: 0px solid; box-sizing: inherit; margin: 0px; padding: 0px; --tw-font-weight: 600; font-weight: 600; -webkit-font-smoothing: antialiased; font-family: ui-sans-serif, -apple-system, system-ui, Segoe UI, Helvetica, Apple Color Emoji, Arial, sans-serif, Segoe UI Emoji, Segoe UI Symbol; line-height: 1.7; color: rgb(248, 250, 252);">single-column indexes</span>.
When you call:

```javascript
table.createIndexes(["CompanyName", "City"]);
```

The table creates **independent indexes** for:

* `CompanyName`
* `City`

Each field is indexed separately.

## Creating Indexes

Indexes are created explicitly.

```javascript
table.createIndexes(["CompanyName", "City"]);
```

Indexes are not created automatically.
If no index exists on a field, search operations fall back to a linear scan.

## Index Persistence

Indexes remain valid:

* After `fetch()`
* After reloading table data

Indexes are only removed when:

```javascript
table.dropIndexes(["City"]);
```

or

```javascript
table.clearIndexes();
```

This allows you to define indexes once and reuse them across data reloads.

## Managing Indexes

### Drop Specific Indexes

```javascript
table.dropIndexes(["City"]);
```

Removes indexes for the specified fields.

### Clear All Indexes

```javascript
table.clearIndexes();
```

Removes all indexed fields.

### Inspect Indexed Fields

```javascript
table.getIndexes();
```

Returns an array of currently indexed field names.
If no indexes exist:

```javascript
[]
```