# maria-developers team mailing list archive

## Re: [GSoC] self-tuning optimizer

```Hi Sergei,

I have been looking into various methods that can meet our conditions. The
Gauss-Seidel Method (
http://en.wikipedia.org/wiki/Gauss%E2%80%93Seidel_method) might meet our
requirements. I had just started writing the code.

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.

Regards
Anshu

On Wed, Jun 25, 2014 at 8:10 PM, Sergei Golubchik <serg@xxxxxxxxxxx> wrote:

> Hi, Anshu!
>
> Please, see the attached patch.
> It introduces a macro top_level_cond_is_satisfied() that now marks all
> places where a comparison (in the TIME_FOR_COMPARE sense) is done.
>
> So, all you need to do is to convert this macro into an (inline) function
> and increment your counter from there.
>
> As for TIME_FOR_COMPARE_ROWID, it's simpler. There's handler::cmp_ref(),
> a virtual handler method. Create handler::ha_cmp_ref(), non-virtual
> inline public method (make cmp_ref() protected, as usual). And increment
> your
> counter from ha_cmp_ref().
>
> By the way, before you start writing the code to solve our equations,
> please write an email, explaining how you're going to solve them, that
> is, what method you'll be using. There are lots of them. Some are
> faster, some are slower. Some work better with sparse matrices (and ours
> will be very much sparse).
>
> Regards,
> Sergei
>
>
```