PostgreSQL Session Parameters
PostgreSQL-compatible TiDB Cloud Starter supports PostgreSQL-compatible session parameters that control transaction behavior, schema resolution, time zones, query timeouts, output formats, and other session settings.
Set and view parameters
Use SET to change a parameter for the current session:
SET statement_timeout = '120s';
Use SET LOCAL to change a parameter only for the current transaction:
BEGIN;
SET LOCAL statement_timeout = '30s';
SELECT *
FROM large_table;
COMMIT;
Use SHOW to view the current value:
SHOW statement_timeout;
List all recognized parameters:
SHOW ALL;
Use RESET to restore one parameter to its default value:
RESET statement_timeout;
Reset all session parameters:
RESET ALL;
Configuration functions
Use current_setting() to read a parameter:
SELECT current_setting('statement_timeout');
Use set_config() to change a parameter:
SELECT set_config(
'statement_timeout',
'120s',
false
);
The third argument controls scope:
false: session scope.true: transaction-local scope.
Common PostgreSQL-compatible parameters
The following commonly used parameters are supported:
SHOW ALL is the best way to inspect the complete parameter set available in the current PostgreSQL-compatible TiDB Cloud Starter instance.
Search path
The search_path parameter controls the schema resolution order.
View the current search path:
SHOW search_path;
Change it for the current session:
SET search_path = app, public;
After this change, an unqualified name is resolved against app before public.
Time zone
View the current time zone:
SHOW timezone;
Set the session time zone:
SET timezone = 'America/Los_Angeles';
Or:
SET TIME ZONE 'UTC';
The session time zone affects display and interpretation of TIMESTAMPTZ values.
Statement timeout
The default statement timeout is 60 seconds.
Increase it for a long-running operation:
SET statement_timeout = '180s';
Disable the statement timeout for the current session:
SET statement_timeout = 0;
Use a larger timeout carefully for operations such as index creation or large data migrations.
Transaction parameters
Set the default isolation level for subsequent transactions:
SET default_transaction_isolation = 'repeatable read';
Make new transactions read-only by default:
SET default_transaction_read_only = on;
View the current transaction settings:
SHOW transaction_isolation;
SHOW transaction_read_only;
Other accepted PostgreSQL parameters
The following PostgreSQL-compatible parameters are also recognized:
default_table_access_methoddefault_tablespacedefault_text_search_configdefault_transaction_deferrableidle_in_transaction_session_timeoutin_hot_standbyinteger_datetimesintervalstylelc_monetarylc_numericlc_timemax_index_keysrow_securityxmloption
The following additional parameters are readable with SHOW:
is_superuserlisten_addressesmax_connectionsportroleserver_versionserver_version_numsession_authorizationtransaction_deferrabletransaction_read_only
Some values are exposed for PostgreSQL client and tool compatibility and do not imply that all corresponding upstream PostgreSQL server functionality is available.
Compatibility-only parameters
Some PostgreSQL parameters are accepted so that PostgreSQL clients and frameworks can initialize sessions successfully, but changing them does not change query behavior.
work_mem
work_mem is accepted and its session value can be changed:
SET work_mem = '64MB';
SHOW work_mem;
The configured value does not control query execution memory in PostgreSQL-compatible TiDB Cloud Starter.
check_function_bodies
check_function_bodies is accepted, but it does not control function-body validation in the same way as PostgreSQL.
SQL statements inside PL/pgSQL function bodies might be validated only when the function is called. Test functions after creating them.
session_replication_role
session_replication_role = 'replica' is not supported.
The following statement is rejected:
SET session_replication_role = 'replica';
Triggers continue to execute with normal origin behavior.
Do not rely on session_replication_role to suppress triggers during bulk loading.
Full-text search parameter
The default_text_search_config parameter controls the default full-text search configuration.
View the current value:
SHOW default_text_search_config;
Set it for the current session:
SET default_text_search_config = 'simple';
Vector search parameter
The hnsw.ef_search parameter controls the HNSW candidate list size for the current session.
View it:
SHOW hnsw.ef_search;
Set it:
SET hnsw.ef_search = 100;
The default value is 40. A higher value can improve recall at the cost of additional query latency.
Embedding parameter
After you enable the embedding extension, the embedding.dimensions parameter controls the output dimension used by supported server-side embedding functions.
For example:
SET embedding.dimensions = 512;