summaryrefslogtreecommitdiff
path: root/storage/spider/ha_spider.h
Commit message (Collapse)AuthorAgeFilesLines
* Fixed limit optimization in range optimizerMonty2023-02-021-0/+1
| | | | | | | | | | | | | The issue was that when limit is used, SQL_SELECT::test_quick_select would set the cost of table scan to be unreasonable high to force a range to be used. The problem with this approach was that range was used even when the cost of range, when it would only read 'limit rows' would be higher than the cost of a table scan. This patch fixes it by not accepting ranges when the range can never have a lower cost than a table scan, even if every row would match the WHERE clause.
* Changing all cost calculation to be given in millisecondsMonty2023-02-021-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes it easier to compare different costs and also allows the optimizer to optimizer different storage engines more reliably. - Added tests/check_costs.pl, a tool to verify optimizer cost calculations. - Most engine costs has been found with this program. All steps to calculate the new costs are documented in Docs/optimizer_costs.txt - User optimizer_cost variables are given in microseconds (as individual costs can be very small). Internally they are stored in ms. - Changed DISK_READ_COST (was DISK_SEEK_BASE_COST) from a hard disk cost (9 ms) to common SSD cost (400MB/sec). - Removed cost calculations for hard disks (rotation etc). - Changed the following handler functions to return IO_AND_CPU_COST. This makes it easy to apply different cost modifiers in ha_..time() functions for io and cpu costs. - scan_time() - rnd_pos_time() & rnd_pos_call_time() - keyread_time() - Enhanched keyread_time() to calculate the full cost of reading of a set of keys with a given number of ranges and optional number of blocks that need to be accessed. - Removed read_time() as keyread_time() + rnd_pos_time() can do the same thing and more. - Tuned cost for: heap, myisam, Aria, InnoDB, archive and MyRocks. Used heap table costs for json_table. The rest are using default engine costs. - Added the following new optimizer variables: - optimizer_disk_read_ratio - optimizer_disk_read_cost - optimizer_key_lookup_cost - optimizer_row_lookup_cost - optimizer_row_next_find_cost - optimizer_scan_cost - Moved all engine specific cost to OPTIMIZER_COSTS structure. - Changed costs to use 'records_out' instead of 'records_read' when recalculating costs. - Split optimizer_costs.h to optimizer_costs.h and optimizer_defaults.h. This allows one to change costs without having to compile a lot of files. - Updated costs for filter lookup. - Use a better cost estimate in best_extension_by_limited_search() for the sorting cost. - Fixed previous issues with 'filtered' explain column as we are now using 'records_out' (min rows seen for table) to calculate filtering. This greatly simplifies the filtering code in JOIN_TAB::save_explain_data(). This change caused a lot of queries to be optimized differently than before, which exposed different issues in the optimizer that needs to be fixed. These fixes are in the following commits. To not have to change the same test case over and over again, the changes in the test cases are done in a single commit after all the critical change sets are done. InnoDB changes: - Updated InnoDB to not divide big range cost with 2. - Added cost for InnoDB (innobase_update_optimizer_costs()). - Don't mark clustered primary key with HA_KEYREAD_ONLY. This will prevent that the optimizer is trying to use index-only scans on the clustered key. - Disabled ha_innobase::scan_time() and ha_innobase::read_time() and ha_innobase::rnd_pos_time() as the default engine cost functions now works good for InnoDB. Other things: - Added --show-query-costs (\Q) option to mysql.cc to show the query cost after each query (good when working with query costs). - Extended my_getopt with GET_ADJUSTED_VALUE which allows one to adjust the value that user is given. This is used to change cost from microseconds (user input) to milliseconds (what the server is internally using). - Added include/my_tracker.h ; Useful include file to quickly test costs of a function. - Use handler::set_table() in all places instead of 'table= arg'. - Added SHOW_OPTIMIZER_COSTS to sys variables. These are input and shown in microseconds for the user but stored as milliseconds. This is to make the numbers easier to read for the user (less pre-zeros). Implemented in 'Sys_var_optimizer_cost' class. - In test_quick_select() do not use index scans if 'no_keyread' is set for the table. This is what we do in other places of the server. - Added THD parameter to Unique::get_use_cost() and check_index_intersect_extension() and similar functions to be able to provide costs to called functions. - Changed 'records' to 'rows' in optimizer_trace. - Write more information to optimizer_trace. - Added INDEX_BLOCK_FILL_FACTOR_MUL (4) and INDEX_BLOCK_FILL_FACTOR_DIV (3) to calculate usage space of keys in b-trees. (Before we used numeric constants). - Removed code that assumed that b-trees has similar costs as binary trees. Replaced with engine calls that returns the cost. - Added Bitmap::find_first_bit() - Added timings to join_cache for ANALYZE table (patch by Sergei Petrunia). - Added records_init and records_after_filter to POSITION to remember more of what best_access_patch() calculates. - table_after_join_selectivity() changed to recalculate 'records_out' based on the new fields from best_access_patch() Bug fixes: - Some queries did not update last_query_cost (was 0). Fixed by moving setting thd->...last_query_cost in JOIN::optimize(). - Write '0' as number of rows for const tables with a matching row. Some internals: - Engine cost are stored in OPTIMIZER_COSTS structure. When a handlerton is created, we also created a new cost variable for the handlerton. We also create a new variable if the user changes a optimizer cost for a not yet loaded handlerton either with command line arguments or with SET @@global.engine.optimizer_cost_variable=xx. - There are 3 global OPTIMIZER_COSTS variables: default_optimizer_costs The default costs + changes from the command line without an engine specifier. heap_optimizer_costs Heap table costs, used for temporary tables tmp_table_optimizer_costs The cost for the default on disk internal temporary table (MyISAM or Aria) - The engine cost for a table is stored in table_share. To speed up accesses the handler has a pointer to this. The cost is copied to the table on first access. If one wants to change the cost one must first update the global engine cost and then do a FLUSH TABLES. This was done to be able to access the costs for an open table without any locks. - When a handlerton is created, the cost are updated the following way: See sql/keycaches.cc for details: - Use 'default_optimizer_costs' as a base - Call hton->update_optimizer_costs() to override with the engines default costs. - Override the costs that the user has specified for the engine. - One handler open, copy the engine cost from handlerton to TABLE_SHARE. - Call handler::update_optimizer_costs() to allow the engine to update cost for this particular table. - There are two costs stored in THD. These are copied to the handler when the table is used in a query: - optimizer_where_cost - optimizer_scan_setup_cost - Simply code in best_access_path() by storing all cost result in a structure. (Idea/Suggestion by Igor)
* MDEV-28526 Spider: remove conn_kind member variablesYuchen Pei2022-12-231-2/+0
| | | | | | | | | | The conn_kind, which stands for "connection kind", is no longer useful because the HandlerSocket support is deleted and Spider now has only one connection kind, SPIDER_CONN_KIND_MYSQL. Remove conn_kind and related code. Signed-off-by: Yuchen Pei <yuchen.pei@mariadb.com> Reviewed-by: Nayuta Yanagisawa <nayuta.yanagisawa@mariadb.com>
* MDEV-27811 Spider: remove #ifdef SPIDER_MDEV_16246Yuichiro Suzuki2022-06-201-4/+0
| | | Reviewed by: Nayuta Yanagisawa
* MDEV-27256 Delete spider_use_handler and related code (2/3)Nayuta Yanagisawa2022-06-091-26/+0
| | | | | | | | Delete the deprecated variable, spider_use_handler and related code. Spider now does not supports accessing data nodes via handler statements. Thus, the notion of SQL kinds are no longer useful. We too discard it.
* MDEV-28226 Spider: remove #ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INCNorio Akagi2022-04-081-4/+0
|
* MDEV-27474 Spider: remove #WITH_PARTITION_STORAGE_ENGINENayuta Yanagisawa2022-03-311-4/+0
| | | | | | "#ifdef WITH_PARTITION_STORAGE_ENGINE ... #endif" appears frequently in the Spider code base. However, there is no need to maintain such ifdefs because Spider is disabled if the partitioning engine is disabled.
* MDEV-27660 Spider: remove #ifdef SPIDER_HANDLER_START_BULK_INSERT_HAS_FLAGS ↵Kento Takeuchi2022-02-111-6/+0
| | | | | | | | | (#2012) Remove unnecessary #ifdefs and dead code in Spider. ha_spider::start_bulk_insert without uint flags is not used because handler::ha_start_bulk_insert calls start_bulk_insert for each storage engine with flags. Therefore, dead code and #ifdef related to SPIDER_HANDLER_START_BULK_INSERT_HAS_FLAGS have been removed.
* MDEV-27659 Spider: remove #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HSNayuta Yanagisawa2022-02-101-71/+0
|
* MDEV-27652 Spider: remove dead code in #ifdef HA_HAS_CHECKSUM_EXTENDEDNayuta Yanagisawa2022-02-101-4/+0
|
* MDEV-27650 Spider: remove #ifdef SPIDER_HAS_GROUP_BY_HANDLERNayuta Yanagisawa2022-02-101-2/+0
|
* MDEV-27647 Spider: remove #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWSNayuta Yanagisawa2022-02-101-14/+0
|
* MDEV-27645 Spider: remove #ifdef HA_MRR_USE_DEFAULT_IMPLNayuta Yanagisawa2022-02-101-39/+0
|
* MDEV-27644 Spider: remove #ifdef HANDLER_HAS_DIRECT_AGGREGATENayuta Yanagisawa2022-02-101-8/+0
|
* MDEV-27643 Spider: remove #ifdef HA_CAN_BULK_ACCESSNayuta Yanagisawa2022-02-101-159/+0
|
* MDEV-27637 Spider: remove #if defined(MARIADB_BASE_VERSION) && ↵Nayuta Yanagisawa2022-02-101-37/+0
| | | | MYSQL_VERSION_ID >= ${VERSION}
* MDEV-26858 Spider: Remove dead code related to HandlerSocketNayuta Yanagisawa2022-01-241-81/+0
| | | | | | Remove the dead-code, in Spider, which is related to the Spider's HandlerSocket support. The code has been disabled for a long time and it is unlikely that the code will be enabled.
* MDEV-27240 SIGSEGV in ha_spider::store_lock on LOCK TABLENayuta Yanagisawa2022-01-151-3/+2
| | | | | | | | | The commit e954d9de gave different lifetime to wide_share and partition_handler_share. This introduced the possibility that partition_handler_share could be accessed even after it was freed. We stop sharing partitoiin_handler_share and make it belong to a single wide_handler to fix the problem.
* MDEV-22246 Result rows duplicated by spider engineKentoku SHIBA2020-08-241-0/+2
| | | | | fix the following type mrr scan (select 0,`id`,`node` from `auto_test_remote`.`tbl_a` where (`id` <> 0) order by `id`)union all(select 1,`id`,`node` from `auto_test_remote`.`tbl_a` where (`id` <> 0) order by `id`) order by `id`
* Added 'final' to some classes to improve generated codeMichael Widenius2020-08-041-1/+1
| | | | | | | | | | | | | | | | | Final added to: - All reasonable classes inhereted from Field - All classes inhereted from Protocol - Almost all Handler classes - Some important Item classes The stripped size of mariadbd is just 4K smaller, but several object files showed notable improvements in common execution paths. - Checked field.o and item_sum.o Other things: - Added 'override' to a few class functions touched by this patch. - Removed 'virtual' from a new class functions that had/got 'override' - Changed Protocol_discard to inherit from Protocol instad of Protocol_text
* remove dead codeSergei Golubchik2020-06-091-10/+0
| | | | | | | | reduce the amount of engine-specific code in the server, particularly as it does not serve any purpose now. may be needed for VP engine, to be reconsidered in MDEV-7795
* prepare for adding new connectors for SpiderKentoku SHIBA2020-06-051-0/+10
| | | | | Conflicts: storage/spider/spd_conn.cc
* fix divided lock table issue of SpiderKentoku SHIBA2020-06-051-0/+1
|
* MDEV-19002 Spider performance optimization with partitionKentoku SHIBA2020-06-051-38/+31
| | | | | | | | | | | Change the following function for batch call instead of each partition - store_lock - external_lock - start_stmt - extra - cond_push - info_push - top_table
* Added page_range to records_in_range() to improve range statisticsMonty2020-03-271-2/+3
| | | | | | | | | | | | | | | | | | | | | | | Prototype change: - virtual ha_rows records_in_range(uint inx, key_range *min_key, - key_range *max_key) + virtual ha_rows records_in_range(uint inx, const key_range *min_key, + const key_range *max_key, + page_range *res) The handler can ignore the page_range parameter. In the case the handler updates the parameter, the optimizer can deduce the following: - If previous range's last key is on the same block as next range's first key - If the current key range is in one block - We can also assume that the first and last block read are cached! This can be used for a better calculation of IO seeks when we estimate the cost of a range index scan. The parameter is fully implemented for MyISAM, Aria and InnoDB. A separate patch will update handler::multi_range_read_info_const() to take the benefits of this change and also remove the double records_in_range() calls that are not anymore needed.
* MDEV-18973 CLIENT_FOUND_ROWS wrong in spiderbb-10.4-MDEV-18973_2Kentoku2019-11-291-6/+11
| | | | | Get count from last_used_con->info Contributed by willhan at Tencent Games
* MDEV-19955 make argument of handler::ha_write_row() constEugene Kosov2019-07-051-1/+1
| | | | | | | | | MDEV-19486 and one more similar bug appeared because handler::write_row() interface welcomes to modify buffer by storage engine. But callers are not ready for that thus bugs are possible in future. handler::write_row(): handler::ha_write_row(): make argument const
* MDEV-16249 CHECKSUM TABLE for a spider table is not parallel and saves all ↵bb-10.4-MDEV-16249Sergei Golubchik2019-06-111-1/+1
| | | | | | | | | | | | | | data in memory in the spider head by default (#1328) followup for be5c432a42e ha_partition::calculate_checksum() has to invoke calculate_checksum() for partitions unconditionally, not under (HA_HAS_OLD_CHECKSUM | HA_HAS_NEW_CHECKSUM). Because the server uses ::info() to ask for a live checksum, while calculate_checksum() must, precisely, calculate it the slow way, also for tables that don't have the live checksum at all. Also, fix the compilation on Windows (ha_checksum/ulonglong type mix).
* MDEV-16249 CHECKSUM TABLE for a spider table is not parallel and saves all ↵Kentoku SHIBA2019-06-111-2/+12
| | | | | data in memory in the spider head by default (#1328) add checksum_null for setting null value of checksum
* Merge 10.2 into 10.3Marko Mäkelä2019-05-141-1/+1
|\
| * Merge 10.1 into 10.2Marko Mäkelä2019-05-131-1/+1
| |\
| | * Merge branch '5.5' into 10.1Vicențiu Ciorbaru2019-05-111-1/+1
| | |
* | | Update Spider to version 3.3.14. Add direct left outer join/right outer ↵Kentoku2019-01-311-15/+77
| | | | | | | | | | | | join/inner join feature
* | | MDEV-16246: insert timestamp into spider table from mysqldump gets wrong ↵Jacob Mathew2018-07-091-20/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | time zone. The problem occurred because the Spider node was incorrectly handling timestamp values sent to and received from the data nodes. The problem has been corrected as follows: - Added logic to set and maintain the UTC time zone on the data nodes. To prevent timestamp ambiguity, it is necessary for the data nodes to use a time zone such as UTC which does not have daylight savings time. - Removed the spider_sync_time_zone configuration variable, which did not solve the problem and which interfered with the solution. - Added logic to convert to the UTC time zone all timestamp values sent to and received from the data nodes. This is done for both unique and non-unique timestamp columns. It is done for WHERE clauses, applying to SELECT, UPDATE and DELETE statements, and for UPDATE columns. - Disabled Spider's use of direct update when any of the columns to update is a timestamp column. This is necessary to prevent false duplicate key value errors. - Added a new test spider.timestamp to thoroughly test Spider's handling of timestamp values. Author: Jacob Mathew. Reviewer: Kentoku Shiba. Cherry-Picked: Commit 97cc9d3 on branch bb-10.3-MDEV-16246
* | | merge Spider 3.3.13Kentoku SHIBA2017-12-031-17/+54
| | | | | | | | | | | | | | | New features in 3.3.13 are: - Join Push Down for 1 by 1 table and single partition.
* | | Adding direct update/delete to the server and to the partition engine.Kentoku SHIBA2017-12-031-7/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for direct update and direct delete requests for spider. A direct update/delete request handles all qualified rows in a single operation rather than one row at a time. Contains Spiral patches: 006_mariadb-10.2.0.direct_update_rows.diff MDEV-7704 008_mariadb-10.2.0.partition_direct_update.diff MDEV-7706 010_mariadb-10.2.0.direct_update_rows2.diff MDEV-7708 011_mariadb-10.2.0.aggregate.diff MDEV-7709 027_mariadb-10.2.0.force_bulk_update.diff MDEV-7724 061_mariadb-10.2.0.mariadb-10.1.8.diff MDEV-12870 - The differences compared to the original patches: - Most of the parameters of the new functions are unnecessary. The unnecessary parameters have been removed. - Changed bit positions for new handler flags upon consideration of handler flags not needed by other Spiral patches and handler flags merged from MySQL. - Added info_push() (Was originally part of bulk access patch) - Didn't include code related to handler socket - Added HA_CAN_DIRECT_UPDATE_AND_DELETE Original author: Kentoku SHIBA First reviewer: Jacob Mathew Second reviewer: Michael Widenius
* | | Add direct aggregatesMonty2017-12-031-12/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Spider patches 026 (MDEV-7723), 031 (MDEV-7727) and 058 (MDEV-12532) This allows the storage engine to internally compute sum and count operations. - Enhance sum items to be able to store the sum value directly. - return_record_by_parent() is enabled in spider as HANDLER_HAS_DIRECT_AGGREGATE is defined - Added spd_environ.h to spider. This is loaded first to ensure that all MariaDB specific defines that are used by include files are properly defined. - This code is tested by the existing spider tests direct_aggregate.test and direct_aggregate_part.test and also partition.test
* | | Adding multi_range_read support to partitionsMonty2017-12-031-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Other things: - Cleanup of allocated bitmaps done in open(), which simplifies init_partition_bitmaps() - Add needed defines in ha_spider.cc to enable new spider code - Fixed some DBUG_PRINT() to be consistent with normal code - Removed end space - The changes in test cases partition_innodb, partition_range, partition_pruning etc are becasue partitions can now more exactly calculate the number of rows in a range. Contains spider patches: 014,015,023,033,035,037,040,042,044,045,049,050,051,053,059
* | | Merge remote-tracking branch 'origin/10.2' into bb-10.2-extAlexander Barkov2017-05-051-0/+2
|\ \ \ | |/ /
| * | MDEV-8954 unnecessary fetch of entire tableJacob Mathew2017-05-011-0/+2
| |/ | | | | | | Merged fix into 10.2.
* | Added "const" to new data for handler::update_row()Michael Widenius2017-04-181-3/+3
|/ | | | | | | | | This was done to make it clear that a update_row() should not change the row. This was not done for handler::write_row() as this function still needs to update auto_increment values in the row. This should at some point be moved to handler::ha_write_row() after which write_row can also have const arguments.
* Correct FSF addressiangilfillan2017-03-101-1/+1
|
* merge spider-3.2.37Kentoku SHIBA2015-10-291-1/+2
|
* Merge Spider 3.2.18Kentoku SHIBA2015-02-201-1/+6
|
* Merge Spider 3.2.11Kentoku SHIBA2014-09-181-0/+4
|
* merge Spider 3.2.4Kentoku SHIBA2014-06-081-0/+1
|
* fix for MariaDB 10.0.8Kentoku SHIBA2014-03-251-1/+1
|
* use handler no where clauseKentoku SHIBA2014-03-251-0/+1
|
* fix bg mrr crashKentoku SHIBA2014-03-251-0/+3
|
* bgs for show recordsKentoku SHIBA2014-03-251-0/+3
|