Skip to content

[Proposal]: Add CSV file bulk load functionality to the community mysql version #94

Description

@NSkeledzija

Pre-flight Checklist

  • I have searched existing GitHub issues and did not find a duplicate proposal.
  • I have removed or redacted sensitive information.

Primary Contact Name

Nikša Skeledžija

Primary Contact Email

niksa.skeledzija@oracle.com

Company / Organization

Oracle

Role

Software Engineer

Additional Authors / Contributors

Annamalai Gurusami annamalai.gurusami@oracle.com

Component

InnoDB

Target Release (Optional)

No response

Roadmap Section

Performance & Observability

Related Issues / Pull Requests / References (Optional)

No response

Executive Summary

Ingesting a lot of raw data from CSV files becomes very slow in certain cases. Regular LOAD DATA statement in mysql boils down to a bunch of INSERTs in the background, which means we do a lot of tree traversals, page allocation just in time, and various other side effects of managing the B+tree inside InnoDB. In some cases, such as when ingesting unsorted data in the range of TBs where the data size exceeds the buffer pool size, we basically grind to a halt and it is not feasible to load such data into the DB. To allow such a use case, we will implement a bulk load algorithm which will deal with this exact scenario where we know up-front that a lot of data is coming in. We can then pre-allocate the extents involved, we can take table level locks up-front, we can sort the data before loading in case the input is unsorted to avoid random page access. We can also leverage the parallel index build infrastructure to build multiple separate sub-trees concurrently and merge them at a later phase by adding a root page.

User / Developer Stories

  • As a developer using mysql, I would like to be able to ingest data coming from various non-mysql sources in CSV files quickly into my database.
  • As a developer using a multi-core machine, I would like mysql to be able to consume as much of my system's resources (cpu cores, RAM) as I specify so it can maximize the ingestion throughput.

Proposed Scope

  • Implement the bulk load functionality which is available by using LOAD DATA ... ALGORITHM=BULK.

Out of Scope / Future Work

  • Non-empty tables require a merge with old data phase, which in some worst case scenarios reduces the performance of bulk load.
  • Partitioned tables require the CSV file distribution per partition to be known up-front and given to bulk loader via the PARTITIONS clause in the LOAD DATA statement.

References

No response

Functional Requirements

No response

Non-functional Requirements

No response

Impact Areas

  • SQL syntax or statements
  • Configuration options or system variables
  • Command-line options or utilities
  • User-visible behavior
  • Observability
  • Security or privilege model
  • Protocol or replication behavior
  • Upgrade / downgrade compatibility
  • Performance or resource usage
  • Files, persistence, or metadata formats
  • APIs or internal interfaces
  • Testing or QA coverage needs

Summary of the Approach

No response

User Interface

No response

Configuration / Knobs

No response

Observability

No response

User Procedure

No response

Security Considerations

No response

Compatibility and Behavior Changes

No response

Block Diagram

No response

Interface Specification

No response

Proposed Implementation Plan

No response

QA Notes

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions