In overall it's not recommended to increase Agent.CommandTimeout too much (like > then 5 seconds) because in situations when agents are slow to respond server will spend too much time waiting.
If your query takes too long, you can use External metric provider - in this case command is executed in the backgound and agent caches values. https://netxms.org/documentation/adminguide/agent-management.html#externalmetricprovider