Skip to content

MAM-SYS/innodb-mysql-order-behavior

Repository files navigation

MySQL Large Data Operations and Buffer Pool Analysis

This repository contains Python scripts designed to interact with a MySQL database, particularly focusing on populating the buffer pool with random data and observing changes in query results. The scripts cover the following tasks:

  • Limit MySQL buffer_pool_size to 5242880
  • Populating a MySQL Table with 2 Billion Records
  • Randomly Querying 1000 Rows to Populate the Buffer Pool
  • Analyzing the Consistency of LIMIT 5 Query Results

Before running the scripts, ensure that you have the following installed:

  • Python 3.x
  • MySQL Server (version 8.0 or higher)
  • Docker (for running MySQL in a container, if needed)

Python Packages:

  • mysql-connector-python

You can install the required Python package using:

poetry install

Setup:

  1. Setting Up MySQL Using Docker
docker compose up -d
  1. Configuring MySQL User Authentication If you encounter the error Authentication plugin 'caching_sha2_password' is not supported, modify the MySQL user's authentication plugin:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'rootpassword';
FLUSH PRIVILEGES;
  1. Creating the Table and Populating with 2 Billion Records Run the Python script to create the table and populate it with 2 billion records:
python3 populate.py
  1. Random Query Execution and Buffer Pool Analysis
pytho3 randomq.py

Observations

Buffer Pool Effects: The consistency of the LIMIT 5 query results will help determine whether changes in the buffer pool affect query results. Result Consistency: If the LIMIT 5 query returns different sequences after different random queries, it suggests that the buffer pool or some other factors might be influencing the order of results.

Conclusion

This set of scripts allows for the examination of how large datasets interact with MySQL's buffer pool, potentially revealing insights into query performance and data retrieval consistency in a heavily loaded database environment.

Here are some links to public forums discussing this topic:

  1. https://www.quora.com/What-is-the-default-order-of-records-for-a-SELECT-statement-in-MySQL#:~:text=There%20is%20NO%20default%20order,specify%20an%20ORDER%20BY%20clause.
  2. https://forums.mysql.com/read.php?21,239471,239688#msg-239688

About

MySQL Large Data Operations and Buffer Pool Analysis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages