Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat(studio): db-pool postgrest config (#22865)

Bobbie Soedirgo9190bbe20619
diff --git a/apps/studio/components/interfaces/Settings/API/PostgrestConfig.tsx b/apps/studio/components/interfaces/Settings/API/PostgrestConfig.tsx
index 6d2110204b1..da72304b181 100644
--- a/apps/studio/components/interfaces/Settings/API/PostgrestConfig.tsx
+++ b/apps/studio/components/interfaces/Settings/API/PostgrestConfig.tsx
@@ -40,7 +40,7 @@ const PostgrestConfig = () => {
)
const formId = 'project-postgres-config'
- const initialValues = { db_schema: '', max_rows: '', db_extra_search_path: '' }
+ const initialValues = { db_schema: '', max_rows: '', db_extra_search_path: '', db_pool: '' }
const updateConfig = async (updatedConfig: typeof initialValues) => {
if (!projectRef) return console.error('Project ref is required')
@@ -49,6 +49,7 @@ const PostgrestConfig = () => {
dbSchema: updatedConfig.db_schema,
maxRows: updatedConfig.max_rows,
dbExtraSearchPath: updatedConfig.db_extra_search_path,
+ dbPool: updatedConfig.db_pool || null,
})
}
@@ -83,6 +84,7 @@ const PostgrestConfig = () => {
db_schema: config.db_schema,
max_rows: config.max_rows,
db_extra_search_path: config.db_extra_search_path ?? '',
+ db_pool: config.db_pool || null,
}
resetForm({ values, initialValues: values })
}
@@ -177,6 +179,17 @@ const PostgrestConfig = () => {
/>
</FormSectionContent>
</FormSection>
+ <FormSection header={<FormSectionLabel>Pool size</FormSectionLabel>}>
+ <FormSectionContent loading={false}>
+ <InputNumber
+ id="db_pool"
+ size="small"
+ disabled={!canUpdatePostgrestConfig}
+ descriptionText="Number of maximum connections to keep open in the Data API server's database pool. Unset to let it be configured automatically based on compute size."
+ placeholder="Configured automatically based on compute size"
+ />
+ </FormSectionContent>
+ </FormSection>
</>
)}
</FormPanel>
diff --git a/apps/studio/data/config/project-postgrest-config-query.ts b/apps/studio/data/config/project-postgrest-config-query.ts
index f278ab01a9b..fcf36806e33 100644
--- a/apps/studio/data/config/project-postgrest-config-query.ts
+++ b/apps/studio/data/config/project-postgrest-config-query.ts
@@ -13,6 +13,7 @@ export type ProjectPostgrestConfigResponse = {
db_schema: string
db_anon_role: string
db_extra_search_path: string
+ db_pool: number | null
jwt_secret: string
}
diff --git a/apps/studio/data/config/project-postgrest-config-update-mutation.ts b/apps/studio/data/config/project-postgrest-config-update-mutation.ts
index 0e319361257..82f1e3409d0 100644
--- a/apps/studio/data/config/project-postgrest-config-update-mutation.ts
+++ b/apps/studio/data/config/project-postgrest-config-update-mutation.ts
@@ -11,6 +11,7 @@ export type ProjectPostgrestConfigUpdateVariables = {
dbSchema: string
maxRows: string
dbExtraSearchPath: string
+ dbPool: string | null
}
export async function updateProjectPostgrestConfig({
@@ -18,11 +19,13 @@ export async function updateProjectPostgrestConfig({
dbSchema,
maxRows,
dbExtraSearchPath,
+ dbPool,
}: ProjectPostgrestConfigUpdateVariables) {
const response = await patch(`${API_URL}/projects/${projectRef}/config/postgrest`, {
db_schema: dbSchema,
max_rows: maxRows,
db_extra_search_path: dbExtraSearchPath,
+ db_pool: dbPool,
})
if (response.error) throw response.error