With older versions, you could use a combination of mqueue, rtimer and sqlops to do kind of asynchronous database operations.
Now, Kamailio 4.2 has a new function - sql_query_async(...) - that delegates the database operation to be done in one of the processes from async pool (new in 4.2 as well). The SIP worker process is immediately ready to process next task in the config or handle next packet from the network. The config file is simpler and performances are higher.
modparam("sqlops","sqlcon","ca=>mysql://username:password@dbhost/dbname") ... sql_query_async("ca","INSERT INTO regstats(username, time) VALUES('$au','$Ts'");