Hop til hovedindhold

Indexes

Indexes in a database use a similar approach as in most non-fiction books: terms and concepts that are frequently looked up by readers are collected in an alphabetic index at the end of the book. The interested reader can scan the index relatively quickly and flip to the appropriate page(s), rather than having to read the entire book to find the material of interest.

Get index

You can either get a single index or a collection of indexes.

All indexes for a table
GET https://api.centia.io/api/v4/schemas/myschema/tables/mytable/indexes HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123
Specific index by name
GET https://api.centia.io/api/v4/schemas/myschema/tables/mytable/indexes/my-btree-index-on-id HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123

An index object looks like this.

{
"name": "btree-on-id",
"columns": ["id"],
"method": "btree"
}

Add index

An index can be of either type btree, brin, gin, gist or hash.

Create an index
POST https://api.centia.io/api/v4/schemas/myschema/tables/mytable/indexes HTTP/1.1
Content-Type: application/json
Authorization: Bearer abc123

{
"name": "my-btree-index-on-id",
"columns": ["id"],
"method": "btree"
}

Delete index

Delete index by name
DELETE https://api.centia.io/api/v4/schemas/myschema/tables/mytable/indexes/my-btree-index-on-id HTTP/1.1