So in a nutshell, Gauss-seidel method is an iterative method. In our case, the initial values for all variables would be obtained by (total_query_time)/total_queries if total_queries not equal to 0, 0 otherwise. After each query, we will get update the value of one variable (which should have a non-zero coefficient in the current equation). We would cycle through all constants query after query. The logic is that after many queries, the values would converge to the correct value. Also updating one variable after each query shouldn't be much of an overhead and we just need to store coefficients for the current query.
The code for this is very simple, I can give a patch in 1-2 days, if the overall idea seems ok.