Hello Sir! Today I made some progress related 1st project MariaDB [a]> create table tbl(abc blob unique); Query OK, 0 rows affected (0.03 sec) MariaDB [a]> insert into tbl values('sachin'); Query OK, 1 row affected, 1 warning (0.01 sec) MariaDB [a]> insert into tbl values('setiya'); Query OK, 1 row affected, 1 warning (0.01 sec) MariaDB [a]> insert into tbl values('sachin'); ERROR 1062 (23000): Duplicate entry '1261' for key 'DB_ROW_HASH_1' MariaDB [a]> desc tbl; +---------------+--------+------+-----+---------+------------+ | Field | Type | Null | Key | Default | Extra | +---------------+--------+------+-----+---------+------------+ | abc | blob | YES | | NULL | | | DB_ROW_HASH_1 | int(4) | YES | UNI | NULL | PERSISTENT | +---------------+--------+------+-----+---------+------------+ 2 rows in set (0.00 sec) MariaDB [a]> I pushed the change in github.Only one thing is remaining is getting the value when hash collides and compare them Regards sachin On Mon, May 16, 2016 at 8:32 PM, Sachin Setia <sachinsetia1001@gmail.com> wrote:
Hello Sergei! Sir please review the prototype at https://github.com/SachinSetiya/server/tree/unique_index_sachin this is half code I guess it will be complete by tomorrow Regards sachin
On Mon, May 2, 2016 at 8:42 PM, Sergei Golubchik <serg@mariadb.org> wrote:
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.
Regards, Sergei Chief Architect MariaDB and security@mariadb.org