Library

How to change path for Firebird temporary files with FIREBIRD_TMP

From the article "FirebirdSQL: internal files, temporary files, and environment variables" you know that location of the Firebird temporary files is governed by the environment variable FIREBIRD_TMP.
If you see that default location for temporary files has lack of space, or if it is situated on the slow drive, you can try to change the path to the temporary Firebird files. For this you need to define FIREBIRD_TMP with the new path.

How to practically change location of temporary Firebird files with FIREBIRD_TMP environment variable?

Linux

To define environment variable in Linux, open Firebird service file () and add to the [service] section:
Environment=FIREBIRD_TMP=/new/path/to/tmp
then update daemon environment and restart Firebird service with the following commands:
systemctl daemon-reload
systemctl restart firebird-superserver

Please note - this approach works for Firebird 3 and Firebird 4. For 2.5, add to the service file the lines with

FIREBIRD_TMP=/new/path/to/tmp
export FIREBIRD_TMP

To check the values of environment variables, use the following command:

strings /proc/PID/environ
where PID is process ID of Firebird server.

After that, temporary files will go to the new path. However, you will be not able to vew them with simple ls command, because they are created in "pre-deleted" mode. To view temporary files in the new path, use the following commands:

 ls -l /proc/PID/fd/|grep deleted
where PID is Firebird process ID.
You will see something like this (if there are active ORDER BY/GROUP BY/DISTINCT queries):
root@ubuntu:/opt/testtmp# ls -l /proc/122999/fd/|grep deleted
lrwx------ 1 firebird firebird 64 Jan 11 01:55 7 -> /opt/testtmp/fb_sort_hFFA8P (deleted)

Windows

On Windows, the easiest way to set it is to run command prompt with Administration priviledges and execute the command:
 setx /m FIREBIRD_TMP  DISK:/Path/To/Temp/Folder
Also, you can open dialog "Edit the system environment variables" and add variable there.

After that, to apply, restart Firebird service.