PostgreSQL query analytics
All paths below use https://api.lordbase.com. Read conventions for headers, authentication, pagination and error handling. Values in responses are illustrative; examples show selected fields, not fixed quotas or service guarantees.
Developer tokens authorize only explicitly supported operations. Required scopes appear below; account, billing and token-management operations require a dashboard session. See token permissions.
Read PostgreSQL query analytics — GET
GET /e/v1/developer/databases/{database_id}/analytics/
Authentication: Authenticated developer with an active Lordbase subscription. Use the dashboard session, or Authorization: Bearer YOUR_DEVELOPER_TOKEN with read_databases (or api). Resource roles and quotas still apply.
Request and permissions: Workspace member; PostgreSQL only; no body. Active database and pg_stat_statements are needed for statistics. Inspect availability and error messages rather than interpreting every zero as no traffic.
Required path parameters: database_id (UUID).
Response: 200
{
"database_id": "11111111-1111-4111-8111-111111111111",
"database_name": "Example PostgreSQL",
"pg_stat_statements_enabled": false,
"total_queries": 0,
"total_calls": 0,
"total_time_ms": 0,
"avg_time_ms": 0,
"slow_queries_count": 0,
"top_consumers": []
}
Failures: Common API errors, plus the validation, role, state, engine and plan restrictions stated above.
List aggregate query statistics — GET
GET /e/v1/developer/databases/{database_id}/analytics/queries/
Authentication: Authenticated developer with an active Lordbase subscription. Use the dashboard session, or Authorization: Bearer YOUR_DEVELOPER_TOKEN with read_databases (or api). Resource roles and quotas still apply.
Request and permissions: Workspace member; PostgreSQL only. Optional integer limit(default 50,max 100), min_calls(default 1), order_by(total_time default,calls,mean_time,rows,shared_blks_hit). Invalid numeric input returns 400; unsupported sort uses total_time. Supply positive counts.
Required path parameters: database_id (UUID).
Response: 200
{
"database_id": "11111111-1111-4111-8111-111111111111",
"database_name": "Example PostgreSQL",
"queries": [
{
"queryid": 123456,
"query": "SELECT $1",
"calls": 10,
"total_time": 5.0,
"mean_time": 0.5,
"min_time": 0.2,
"max_time": 1.0,
"rows": 10,
"shared_blks_hit": 10,
"shared_blks_read": 0,
"shared_blks_written": 0,
"query_truncated": "SELECT $1",
"cache_hit_ratio": 100.0
}
],
"count": 1
}
Failures: Common API errors, plus the validation, role, state, engine and plan restrictions stated above.
Find slow PostgreSQL queries — GET
GET /e/v1/developer/databases/{database_id}/analytics/slow/
Authentication: Authenticated developer with an active Lordbase subscription. Use the dashboard session, or Authorization: Bearer YOUR_DEVELOPER_TOKEN with read_databases (or api). Resource roles and quotas still apply.
Request and permissions: Workspace member; PostgreSQL only. Optional numeric threshold_ms(default 1000) and integer limit(default 20,max 50). Threshold applies to mean query time; malformed numeric parameters return400.
Required path parameters: database_id (UUID).
Response: 200
{
"database_id": "11111111-1111-4111-8111-111111111111",
"database_name": "Example PostgreSQL",
"threshold_ms": 1000,
"queries": [
{
"queryid": 123456,
"query": "SELECT example_operation()",
"calls": 2,
"total_time": 3000.0,
"mean_time": 1500.0,
"max_time": 1800.0,
"rows": 2,
"query_truncated": "SELECT example_operation()"
}
],
"count": 1
}
Failures: Common API errors, plus the validation, role, state, engine and plan restrictions stated above.
List running PostgreSQL queries — GET
GET /e/v1/developer/databases/{database_id}/analytics/active/
Authentication: Authenticated developer with an active Lordbase subscription. Use the dashboard session, or Authorization: Bearer YOUR_DEVELOPER_TOKEN with read_databases (or api). Resource roles and quotas still apply.
Request and permissions: Workspace member; PostgreSQL only; no body.
Required path parameters: database_id (UUID).
Response: 200
{
"database_id": "11111111-1111-4111-8111-111111111111",
"database_name": "Example PostgreSQL",
"queries": [
{
"pid": 1234,
"username": "lb_example_app",
"application_name": "example",
"client_addr": "203.0.113.10",
"state": "active",
"query": "SELECT example_operation()",
"query_start": "2026-10-27T12:00:00Z",
"duration_seconds": 1.5,
"wait_event_type": null,
"wait_event": null,
"query_truncated": "SELECT example_operation()"
}
],
"count": 1
}
Failures: Common API errors, plus the validation, role, state, engine and plan restrictions stated above.
Reset PostgreSQL query statistics — POST
POST /e/v1/developer/databases/{database_id}/analytics/reset/
Authentication: Authenticated developer with an active Lordbase subscription. Use the dashboard session, or Authorization: Bearer YOUR_DEVELOPER_TOKEN with write_databases (or api). Resource roles and quotas still apply.
Request and permissions: Owner/admin; PostgreSQL only; no body. Removes the accumulated statistics baseline. Failure returns 400 with success:false.
Required path parameters: database_id (UUID).
Response: 200
{
"database_id": "11111111-1111-4111-8111-111111111111",
"success": true,
"message": "Statistics reset successfully"
}
Failures: Common API errors, plus the validation, role, state, engine and plan restrictions stated above.