Skip to content
This repository was archived by the owner on Jun 12, 2020. It is now read-only.

Bulk Fetch

RIch Prohaska edited this page Jul 16, 2014 · 54 revisions

Introduction

The TokuDB bulk fetch algorithm speeds up fractal tree scans by returning multiple rows per tree search rather than a single row. This amortizes the cost of a fractal tree search over several rows. We have observed a speedup of between 2x and 5x when using bulk fetch compared to not using it.

Index and range scans

The MySQL query executor uses one of several table scanning algorithms to read rows from a table. An index scan is used to retrieve all of the rows from an index. A range scan is used to retrieve all of the rows from an index within a key range. TokuDB can use its bulk fetch algorithm for both of these types of scans. However, TokuDB must be notified by the MySQL query executor that an index or range scan will happen. The prepare_index_scan handler method informs the storage engine that an index scan will happen. Similarly, the prepare_range_scan handler method informs the storage engine that a range scan will happen. We placed calls to these methods in the appropriate places of the MySQL query executor code.

Queries that use index or range scans

  1. Simple select
    • select ... from s where ...
    • Partition bug documented in #261
  2. Create select
    • create table t as select ... from s where ...
    • Fixed in #262
    • create temporary table t as select ... from s where ...
    • Create temporary table documented in #143
  3. Insert select
    • insert into t select ... from s where ...
    • Fixed in #263
  4. Range delete
    • delete from t where ...
    • Documented in #264
  5. Range update
    • update t set ... where ...
    • Documented in #265

Partitioned tables

Bulk fetch should be used for index and range scans on simple tables as well as partitioned tables.

We recently found that bulk fetch is NOT being used for index scans on partitioned TokuDB tables. The bug is described here. Index scans on partitions do not use bulk fetch because the tokudb::prepare_index_scan method is not currently called by the partition storage engine. We will either (1) call it from the partition storage engine, or (2) have the TokuDB figure out that an index scan is happening and then start bulk fetch.

Current Implementation

Alternate Implementation

Why not start the bulk fetch algorithm when the tokudb::index_next is called and bulk fetch is not yet started?

Clone this wiki locally