mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Original idea from Zardosht Kasheff to add HA_CLUSTERED_INDEX
- Added a lot of code comments - Updated get_best_ror_intersec() to prefer index scan on not clustered keys before clustered keys. - Use HA_CLUSTERED_INDEX to define if one should use HA_MRR_INDEX_ONLY - For test of using index or filesort to resolve ORDER BY, use HA_CLUSTERED_INDEX flag instead of primary_key_is_clustered() - Use HA_TABLE_SCAN_ON_INDEX instead of primary_key_is_clustered() to decide if ALTER TABLE ... ORDER BY will have any effect. sql/ha_partition.h: Added comment with warning for code unsafe to use with multiple storage engines at the same time sql/handler.h: Added HA_CLUSTERED_INDEX. Documented primary_key_is_clustered() sql/opt_range.cc: Added code comments Updated get_best_ror_intersec() to ignore clustered keys. Optimized away cpk_scan_used and one instance of current_thd (Simpler code) Use HA_CLUSTERED_INDEX to define if one should use HA_MRR_INDEX_ONLY sql/sql_select.cc: Changed comment to #ifdef For test of using index or filesort to resolve ORDER BY, use HA_CLUSTERED_INDEX flag instead of primary_key_is_clustered() (Change is smaller than what it looks beause of indentation change) sql/sql_table.cc: Use HA_TABLE_SCAN_ON_INDEX instead of primary_key_is_clustered() to decide if ALTER TABLE ... ORDER BY will have any effect. storage/innobase/handler/ha_innodb.h: Added support for HA_CLUSTERED_INDEX storage/innodb_plugin/handler/ha_innodb.cc: Added support for HA_CLUSTERED_INDEX storage/xtradb/handler/ha_innodb.cc: Added support for HA_CLUSTERED_INDEX
This commit is contained in:
@@ -161,8 +161,11 @@
|
||||
*/
|
||||
#define HA_KEY_SCAN_NOT_ROR 128
|
||||
#define HA_DO_INDEX_COND_PUSHDOWN 256 /* Supports Index Condition Pushdown */
|
||||
|
||||
|
||||
/*
|
||||
Data is clustered on this key. This means that when you read the key
|
||||
you also get the row data in the same block.
|
||||
*/
|
||||
#define HA_CLUSTERED_INDEX 512
|
||||
|
||||
/*
|
||||
bits in alter_table_flags:
|
||||
@@ -2311,9 +2314,22 @@ public:
|
||||
|
||||
|
||||
/*
|
||||
@retval TRUE Primary key (if there is one) is clustered
|
||||
key covering all fields
|
||||
@retval FALSE otherwise
|
||||
Check if the primary key (if there is one) is a clustered key covering
|
||||
all fields. This means:
|
||||
|
||||
- Data is stored together with the primary key (no secondary lookup
|
||||
needed to find the row data). The optimizer uses this to find out
|
||||
the cost of fetching data.
|
||||
- The primary key is part of each secondary key and is used
|
||||
to find the row data in the primary index when reading trough
|
||||
secondary indexes.
|
||||
- When doing a HA_KEYREAD_ONLY we get also all the primary key parts
|
||||
into the row. This is critical property used by index_merge.
|
||||
|
||||
For a clustered primary key, index_flags() returns also HA_CLUSTERED_INDEX
|
||||
|
||||
@retval TRUE yes
|
||||
@retval FALSE No.
|
||||
*/
|
||||
virtual bool primary_key_is_clustered() { return FALSE; }
|
||||
virtual int cmp_ref(const uchar *ref1, const uchar *ref2)
|
||||
|
Reference in New Issue
Block a user