How to change storage destination for database files in QuestDB?

I tried to change directory in config file. As I want to save all data on disk D as it has more free space.

What I did is that I change: # directory for storing db tables and metadata. this directory is inside the server root directory provided at startup


But I got this error:

could not open read-write [file=C:\WINDOWS\system32\qdbroot\D:_tab_index.d]

Documentation could be better, but cairo.root is not really the root directory for QuestDB. You should leave the default value of db for that configuration parameter on server.conf before you continue. I will provide more context at the end of this answer.

QuestDB uses a default directory by default when you run start, depending on the OS, which for windows is C:\Windows\System32\qdbroot. Unless you explicitly pass a different root folder on startup, that folder will be used. Since the server.conf file is only read after the root folder has been determined, the configuration cairo.root wouldn’t have any effect for this.

So, if you want to change the root directory to the D:\ drive, you should start with something like: questdb.exe start -d D:\qdbroot

Make sure the folder D:\qdbroot exists and the questdb service was not already started. If the service was started, you can issue questdb.exe stop.

If you have registered questdb as a service it via questdb.exe install, it will always use the default folder, but this can be changed. You need first to deregister the service with questdb.exe remove and then install again passing the -d parameter, as in:

questdb.exe install -d D:\qdbroot.

Again, make sure the folder D:\qdbroot exists. This will cause questdb to start as a service on startup of your system.

Now, what is the cairo.root config for then?. Well, QuestDB has by default this root directory structure:

├── conf
├── db
├── log
├── public
└── snapshot (optional)

The cairo.root folder makes reference to the db folder inside the root folder, which is why you get an error when changing that key on the config file. That property is only checked when doing things like attaching or detaching partitions, and you are better off just leaving the default value.