Saturday, May 21, 2016

Building items clones

Finially I finished my project on recursive CTE, so I can resume working on my project of GSOC 2016.

As I said in my previous post, I decided to start with building items clones (items are used to build different kinds of expressions in MySQL).

Items are typical tree structures. If I just copy a node in the item structure, pointers to the subtrees won't be right. Fortunately this pointers can be fixed in the method Item_func_or_sum::build_clone. To copy nodes we use copy constructor. As we don't know the type of the node in general the copy constructor should be virtual. I called it get_copy. It should be implemented for each terminal class of items. There are dozens of such classes.

How they could be caught?

I used the following trick.
My get_copy for the base class Item is 'pseudo-abstract':

Item *tem::get_copy(...) { dbug_print_item(this); DBUG_ASSERT(0); return 0; }

Here dbug_print_item(this) helps me to understand for which class get_copy is missed.
If I call now method build_clone, for example in JOIN::optimize_inner(), to build a clone for the WHERE condition, and launch tests, it'll be easy for me to understand for which classes lack implementations of get_copy.

Here I've faced some minor problem: how to skip the queries that are excuted by mtr before it starts running the tests.
Anybody knows?
(Now I have a workaround: call build_clone() conditinally and manually trigger the condition. Of course it's not nice.)

Thursday, May 5, 2016


First of all I went on github (my nick there is shagalla) and cloned a server code from my tree into the new branch. I called it 10.2-mdev9197 and I'm going to do all my work on it. As I had worked with MariaDB server before on my previous projects (on implementation of common table expressions), building server code was really not so difficult for me.
So I solved my first task successfully during the community bonding period!

Now it's time to talk about my project in detail.
If you are interested in it you can read about it on jira, just click this link -> click 

As you see, it's an optimization work and its main goal is to make the query faster. Now it's slow because any view/derived table defined by a grouping query (look at the example on jira) is first materialized in a temporary table.

To solve this problem I suggested to divide my work into a few issues:

1. Implementation of the case with separable conditions (conjunctive conditions that depend only on view/derived table columns)
2. Implementation of the case with non-separable conditions (there are no conjunctive conditions depending only on the columns of view/derived table, but still some restrictive condition depending only on view/derived table can be extracted from the where clause)
3. Building item clones (it's necessary for issue 2)
4. Implementation of the case with semantically separable conditions
5. Implementation of the case with separable conditions when several views are used
6. Detection of semantically separable conditions for comparison predicates.

I'm going to give you information in detail while considering each issue.

I talked with igor_seattle and we decided to start with building item clones.
In general case building a clone for an item is quite a big task (e.g. when the item contains subquery), but it's not so difficult for simple predicates and functions (like inequality, addition) if we use copy constructors.

In my next post I'm going to tell you about my progress in solving this particular problem.

Wednesday, May 4, 2016

Community bonding


My name is Galina Shalygina and this summer I'll be working on the project for GSoC with MariaDB company. I'm so happy to be the part of GSoC, it's such an interesting experience!
The title of my project is 'Pushing conditions into non-mergeable views and derived tables in MariaDB'. My mentors on this projects will be Igor Babaev and Sergey Petrunya. 

Now, during the community bonding period (April 22 - May 22) I'm going to:

1. Clone server code and build it;
2. Read documentation;
3. Study all developments on my theme;
4. For this project I will need to be able to clone expressions, so I'll start to work on solving this problem.