Indices
Indices 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.
Add index
An index can be of either type btree, brin, gin, gist or hash.
- HTTP
- CLI
Create an index
POST https://api.centia.io/api/v4/schemas/rockhall/tables/inductees/indices HTTP/1.1
Content-Type: application/json
Authorization: Bearer abc123
{
"name": "inductees-id-btree",
"columns": ["id"],
"method": "btree"
}
centia index add "rockhall" "inductees" "id" btree "inductees-id-btree"
Get index
You can either get a single index or a collection of indices.
- HTTP
- CLI
All indices for a table
GET https://api.centia.io/api/v4/schemas/rockhall/tables/inductees/indices HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123
Specific index by name
GET https://api.centia.io/api/v4/schemas/rockhall/tables/inductees/indices/my-btree-index-on-id HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123
centia index get "rockhall" "inductees" "btree-on-id"
An index object looks like this.
{
"name": "btree-on-id",
"columns": ["id"],
"method": "btree"
}
Delete index
- HTTP
- CLI
Delete index by name
DELETE https://api.centia.io/api/v4/schemas/rockhall/tables/inductees/indices/inductees-id-btree HTTP/1.1
centia index drop "rockhall" "inductees" "id" "inductees-id-btree"