summaryrefslogtreecommitdiff
path: root/sql/mdl.h
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2014-03-06 16:19:12 +0400
committerSergey Vojtovich <svoj@mariadb.org>2014-03-06 16:19:12 +0400
commitb95c8ce530cbbd92b232324dc2c4376615bd1b5d (patch)
tree60222ef1542c97949e24dcbc4474f5484b86119b /sql/mdl.h
parentae87e63184a451cd0c9cf95f11f51b78bb40fbc3 (diff)
downloadmariadb-git-b95c8ce530cbbd92b232324dc2c4376615bd1b5d.tar.gz
MDEV-5675 - Performance: my_hash_sort_bin is called too often
Reduced number of my_hash_sort_bin() calls from 4 to 1 per query. Reduced number of memory accesses done by my_hash_sort_bin(). Details: - let MDL subsystem use pre-calculated hash value for hash inserts and deletes - let table cache use pre-calculated MDL hash value - MDL namespace is excluded from hash value calculation, so that hash value can be used by table cache as is - hash value for MDL is calculated as resulting hash value + MDL namespace - extended hash implementation to accept user defined hash function
Diffstat (limited to 'sql/mdl.h')
-rw-r--r--sql/mdl.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/sql/mdl.h b/sql/mdl.h
index c7c445c75e1..6f31b46f17f 100644
--- a/sql/mdl.h
+++ b/sql/mdl.h
@@ -28,6 +28,7 @@
#include <my_sys.h>
#include <m_string.h>
#include <mysql_com.h>
+#include <hash.h>
#include <algorithm>
@@ -347,12 +348,15 @@ public:
m_ptr - 1);
m_length= static_cast<uint16>(strmake(m_ptr + m_db_name_length + 2, name,
NAME_LEN) - m_ptr + 1);
+ m_hash_value= my_hash_sort(&my_charset_bin, (uchar*) m_ptr + 1,
+ m_length - 1);
}
void mdl_key_init(const MDL_key *rhs)
{
memcpy(m_ptr, rhs->m_ptr, rhs->m_length);
m_length= rhs->m_length;
m_db_name_length= rhs->m_db_name_length;
+ m_hash_value= rhs->m_hash_value;
}
bool is_equal(const MDL_key *rhs) const
{
@@ -392,15 +396,26 @@ public:
{
return & m_namespace_to_wait_state_name[(int)mdl_namespace()];
}
+ my_hash_value_type hash_value() const
+ {
+ return m_hash_value + mdl_namespace();
+ }
+ my_hash_value_type tc_hash_value() const
+ {
+ return m_hash_value;
+ }
private:
uint16 m_length;
uint16 m_db_name_length;
+ my_hash_value_type m_hash_value;
char m_ptr[MAX_MDLKEY_LENGTH];
static PSI_stage_info m_namespace_to_wait_state_name[NAMESPACE_END];
private:
MDL_key(const MDL_key &); /* not implemented */
MDL_key &operator=(const MDL_key &); /* not implemented */
+ friend my_hash_value_type mdl_hash_function(const CHARSET_INFO *,
+ const uchar *, size_t);
};