Delete Index
Remove database indexes that are no longer needed. This operation helps optimize database performance by freeing up storage space and reducing maintenance overhead for unused indexes.
danger
Deleting an index can significantly slow down queries that relied on it. Ensure the index has low or zero usage (idx_scan near 0) and that no critical workflows depend on it. Dropping an index requires a brief exclusive lock on the table.
Method Signature
deleteIndex(
tableName: string,
indexName: string
): Promise<BolticSuccessResponse<DeleteIndexResponse> | BolticErrorResponse>
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
tableName | string | ✅ | Name of the table that contains the index |
indexName | string | ✅ | Name of the index to delete (exact name from create/list operations) |
Response
interface DeleteIndexResponse {
data: object;
message: string;
}
Examples
import { createClient } from "@boltic/sdk";
const client = createClient("your-api-key");
// Delete an index by name
const { data: result, error } = await client.indexes.deleteIndex("users", "users_btree_email");
if (error) {
console.error("Failed to delete index:", error.message);
} else {
console.log("Index deleted successfully:", result.message);
}
Chained Access Method
// Using chained access pattern
const { data: result } = await client.from("users").indexes().deleteIndex("users_btree_email");