diff options
author | Varun Gupta <varun.gupta@mariadb.com> | 2020-03-28 12:31:22 +0530 |
---|---|---|
committer | Varun Gupta <varun.gupta@mariadb.com> | 2020-06-29 14:04:07 +0530 |
commit | 077b71e4e5e5ad4aa2b4a7f6a1b49d457f5ceb55 (patch) | |
tree | c4a09ebb32e662a1243c23601ab6bd65a321668f /sql/field.h | |
parent | ead98fe5d34912578445d42e620c8ed95df4c433 (diff) | |
download | mariadb-git-10.5-varun2.tar.gz |
MDEV-21829: Use packed sort keys in Unique objects10.5-varun2
The task deals with packing the values stored in the Unique tree for each record.
The changes brought by this feature is:
1) Unique tree can have dynamic length keys
2) Format of keys looks like
<key_length> <packed_value1> <packed_value2> ....... <packed_valueN>
Unique class is currently used in
1) agg_func(DISTINCT col)
Here most aggregate functions like SUM, AVG accept only fixed size arguments
so it is not beneficial to use packing for these. Packing is done for
COUNT and GROUP_CONCAT (or JSON_ARRAYAGG) aggregate function as these are meaningful
2) index-merge stores row-ids
index merge stores row-ids which are of fixed size, so packing is not required
3) Engine Independent Table statistics
Packing is done here for variable length data types
This task is an extension to MDEV-21580.
Diffstat (limited to 'sql/field.h')
-rw-r--r-- | sql/field.h | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/sql/field.h b/sql/field.h index e4c5ffcc0de..693d0b63ded 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1109,6 +1109,11 @@ public: */ virtual uint32 data_length() { return pack_length(); } virtual uint32 sort_length() const { return pack_length(); } + /* + returns the sort_length for a field without the suffix length bytes + for fields with binary charset. + */ + virtual uint32 sort_length_without_suffix() const { return pack_length(); } /* sort_suffix_length() return the length bytes needed to store the length @@ -1316,9 +1321,21 @@ public: } return update_fl; } + + /* + @brief + Make a packed value for a field + @param + to buffer to store the value + */ + virtual uint make_packed_record_field(uchar *to) + { + uchar* end= pack(to, ptr); + return static_cast<uint>(end - to); + } virtual void store_field_value(uchar *val, uint len) { - memcpy(ptr, val, len); + memcpy(ptr, val, len); } virtual uint decimals() const { return 0; } virtual Information_schema_numeric_attributes @@ -4122,6 +4139,10 @@ public: { return (uint32) field_length + sort_suffix_length(); } + uint32 sort_length_without_suffix() const override + { + return (uint32) field_length; + } virtual uint32 sort_suffix_length() const override { return (field_charset() == &my_charset_bin ? length_bytes : 0); @@ -4463,6 +4484,10 @@ public: { return (uint32) (packlength); } uint row_pack_length() const override { return pack_length_no_ptr(); } uint32 sort_length() const override; + uint32 sort_length_without_suffix() const override + { + return field_length; + } uint32 sort_suffix_length() const override; uint32 value_length() override { return get_length(); } virtual uint32 max_data_length() const override |