DEV Community

Michael
Michael

Posted on • Originally published at gbase8.cn

Temporarily Changing Session‑Level Parameters in GBase 8a

Some parameters in GBase 8a can be modified at the session level, affecting only the current connection. When using connection pools, it's a good practice to save the original value, apply the temporary change, and restore it afterwards to avoid impacting subsequent queries. Here's the safe workflow for a gbase database.

Steps

  1. Save the current value – Use SELECT @@parameter_name and store it in a user variable.
  2. Change the parameter – Use SET parameter_name = new_value.
  3. Restore the parameter – After the specific query completes, SET parameter_name = @saved_variable.

Complete Example

-- 1. Inspect and save the current value
SELECT @@estimate_func_max_len;
-- Returns 0
SET @bak = @@estimate_func_max_len;

-- 2. Temporarily change the parameter
SET estimate_func_max_len = 32700;
SHOW VARIABLES LIKE 'esti%';
-- Shows Value = 32700

-- 3. Restore the original value
SET estimate_func_max_len = @bak;
SHOW VARIABLES LIKE 'esti%';
-- Shows Value = 0
Enter fullscreen mode Exit fullscreen mode

This pattern lets you tune parameters for specific queries without permanently altering the session environment, keeping your gbase database connections clean and predictable.

Top comments (0)