Hi, Sachin!
On May 02, Sachin Setia wrote:
> Hi Sergei!
>
> As i told you i was prototyping for hash table
> It is done around 90% apart from one thing when hash is same
> how to get record from .myd file when i have offset of record
> so currently i am skipping it
> But it is very fast i do not know why this is so fast here are
> results of employee database
> salary table definition
> CREATE TABLE salaries (
> emp_no INT NOT NULL,
> salary blob NOT NULL,
> from_date DATE NOT NULL,
> to_date DATE NOT NULL,
> FOREIGN KEY (emp_no) REFERENCES employees (emp_no) ON DELETE CASCADE,
> PRIMARY KEY (emp_no, from_date)
> )
I presume, you had ENGINE=Aria here? Because your code patch is for Aria.
> ;
> And query is
> MariaDB [employees]> select distinct salary from salaries;
>
> Result with out using hash table
>
> +--------+
> 85814 rows in set (2 min 24.76 sec)
>
>
> Result with using hash table
>
> | 39420 |
> +--------+
> 85809 rows in set (6.24 sec)
>
> ( number of rows are not equal but this can be solved if i get record by
> offset)
>
> I am sure there is something wrong.The whole hash table is in memory
> like wise the b tree of hash is in memory but why there is so much
> improvement. Please sir check the prototype and tell if i am wrong
> .thanks
Sure.
But still, please put your code on github and commit often.
Let's use a proper development process instead of sending patches back
and forth. If you need help with that, feel free to ping me on irc.
And using // comments makes the code more difficult to review - you
change every line in a big block. Better use
#if 0
...
#endif
> diff --git a/storage/maria/ma_hash_table.h b/storage/maria/ma_hash_table.h
> new file mode 100644
> index 0000000..c8e4578
> --- /dev/null
> +++ b/storage/maria/ma_hash_table.h
why are you doing it in Aria? I thought we've agreed to do it on the
upper level, in sql/
> @@ -0,0 +1,45 @@
> +#include"../../mysys/my_malloc.c"
> +#include"../../include/my_global.h"
> +typedef struct ma_hash_table_element{
> + unsigned int hash_code;
> + unsigned int record_offset;
> + struct ma_hash_table * next; //we will use single link list because no delete operations
> +} ma_hash_table_element;
Did you look at reusing the HASH data structure? include/hash.h, mysys/hash.c?
> +
> +typedef struct ma_hash_table{
> + unsigned int size;
> + ma_hash_table_element * h_t_e;
> +}ma_hash_table;
Because of the above (on the wrong level, ma_hash_table instead of HASH,
using // comments to disable code) I've only quickly looked through the patch.
But I didn't notice anything obviously wrong.