mariadb/storage/federatedx
Monty d9d0e78039 Add limits for how many IO operations a table access will do
This solves the current problem in the optimizer
- SELECT FROM big_table
  - SELECT from small_table where small_table.eq_ref_key=big_table.id

The old code assumed that each eq_ref access will cause an IO.
As the cost of IO is high, this dominated the cost for the later table
which caused the optimizer to prefer table scans + join cache over
index reads.

This patch fixes this issue by limit the number of expected IO calls,
for rows and index separately, to the size of the table or index or
the number of accesses that we except in a range for the index.

The major changes are:

- Adding a new structure ALL_READ_COST that is mainly used in
  best_access_path() to hold the costs parts of the cost we are
  calculating. This allows us to limit the number of IO when multiplying
  the cost with the previous row combinations.
- All storage engine cost functions are changed to return IO_AND_CPU_COST.
  The virtual cost functions should now return in IO_AND_CPU_COST.io
  the number of disk blocks that will be accessed instead of the cost
  of the access.
- We are not limiting the io_blocks for table or index scans as we
  assume that engines may not store these in the 'hot' part of the
  cache. Table and index scan also uses much less IO blocks than
  key accesses, so the original issue is not as critical with scans.

Other things:
  OPT_RANGE now holds a 'Cost_estimate cost' instead a lot of different
  costs. All the old costs, like index_only_read, can be extracted
  from 'cost'.
- Added to the start of some functions 'handler *file= table->file'
  to shorten the code that is using the handler.
- handler->cost() is used to change a ALL_READ_COST or IO_AND_CPU_COST
  to 'cost in milliseconds'
- New functions:  handler::index_blocks() and handler::row_blocks()
  which are used to limit the IO.
- Added index_cost and row_cost to Cost_estimate and removed all not
  needed members.
- Removed cost coefficients from Cost_estimate as these don't make sense
  when costs (except IO_BLOCKS) are in milliseconds.
- Removed handler::avg_io_cost() and replaced it with DISK_READ_COST.
- Renamed best_range_rowid_filter_for_partial_join() to
  best_range_rowid_filter() as using the old name made rows too long.
- Changed all SJ_MATERIALIZATION_INFO 'Cost_estimate' variables to
  'double' as Cost_estimate power was not used for these and thus
  just caused storage and performance overhead.
- Changed cost_for_index_read() to use 'worst_seeks' to only limit
  IO, not number of table accesses. With this patch worst_seeks is
  probably not needed anymore, but I kept it around just in case.
- Applying cost for filter got to be much shorter and easier thanks
  to the API changes.
- Adjusted cost for fulltext keys in collaboration with Sergei Golubchik.
- Most test changes caused by this patch is that table scans are changed
  to use indexes.
- Added ha_seq::keyread_time() and ha_seq::key_scan_time() to get
  make checking number of potential IO blocks easier during debugging.
2023-02-02 23:57:30 +03:00
..
AUTHORS Lintian complains on spelling error 2019-12-02 12:41:13 +02:00
ChangeLog
CMakeLists.txt Merge branch '10.5' into 10.6 2022-11-02 14:33:20 +01:00
FAQ
federatedx_io.cc Remove unused declarations 2019-04-03 19:46:34 +03:00
federatedx_io_mysql.cc Merge branch '10.6' into 10.7 2022-11-02 15:45:27 +01:00
federatedx_io_null.cc Merge branch '10.2' into 10.3 2020-12-23 19:28:02 +01:00
federatedx_probes.h
federatedx_pushdown.cc Merge branch '10.4' into 10.5 2022-10-26 15:26:06 +02:00
federatedx_pushdown.h MDEV-17096 Pushdown of simple derived tables to storage engines 2019-02-09 22:54:26 -08:00
federatedx_txn.cc MDEV-29613 fixup: clang -Wunused-but-set-variable 2022-09-26 15:16:51 +03:00
ha_federatedx.cc Changing all cost calculation to be given in milliseconds 2023-02-02 23:54:45 +03:00
ha_federatedx.h Add limits for how many IO operations a table access will do 2023-02-02 23:57:30 +03:00
README
README.windows CRLF->LF 2015-06-02 22:07:47 +02:00

This is the FederatedX Storage Engine, developed as an external storage engine.

NOTE:

The following is only relevant if you use it for MySQL.  MariaDB already comes
with the latest version of FederatedX.

To install, grab a copy of the mysql source code and run this:

./configure --with-mysql=/path/to/src/mysql-5.x --libdir=/usr/local/lib/mysql/

make install

And then inside of MySQL:

mysql> INSTALL PLUGIN federatedx SONAME 'libfederatedx_engine.so';

mysql> CREATE TABLE `d` (`a` varchar(125), b text, primary key(a)) ENGINE=FEDERATEDX CONNECTION="mysql://root@host/schema/table"

or 

mysql> CREATE TABLE `d` (`a` varchar(125), b text, primary key(a)) ENGINE=FEDERATEDX CONNECTION="server" CHARSET=latin1;

You will probably need to edit the Makefile.am in the src/ tree if you want
to build on anything other then Linux (and the Makefile assumes that the
server was not compiled for debug). The reason for the two possible
configure lines is that libdir is dependent on where MySQL was installed. If
you run the "INSTALL PLUGIN ..." and you get a file not found, check that
your configured this directory correctly.

For Solaris you can enable DTrace probes by adding to configure
--enable-dtrace