22 | Contribution Guidelines (Expand for Details)
23 |
24 | We appreciate your contribution to VIDEX! To ensure a smooth review process and maintain high code quality, please adhere to the following guidelines:
25 |
26 | Pull Request Title Format
27 | Your PR title should start with one of these prefixes to indicate the nature of the change:
28 |
29 | [Core]
: Changes to core engine functionality
30 | [Opt]
: Changes to VIDEX-Optimizer-Plugin
31 | [Stats]
: Changes to VIDEX-Statistic-Server
32 | [Algo]
: Implementation of new algorithms for NDV, cardinality estimation, etc.
33 | [Pipe]
: Enhancements to the pipeline (e.g., data collection, environment setup)
34 | [Bug]
: Corrections to existing functionality
35 | [CI]
: Changes to build process or CI pipeline
36 | [Docs]
: Updates or additions to documentation
37 | [Test]
: Adding or updating tests
38 | [Perf]
: Performance improvements
39 | [Misc]
: For changes not covered above (use sparingly)
40 |
41 | Note: For changes spanning multiple categories, use the most specific prefix or multiple prefixes in order of importance (e.g., [Algorithm][Stats]).
42 |
43 | Submission Checklist
44 |
45 | - [ ] PR title includes appropriate prefix(es)
46 | - [ ] Changes are clearly explained in the PR description
47 | - [ ] New and existing tests pass successfully
48 | - [ ] Code adheres to project style and best practices
49 | - [ ] Documentation updated to reflect changes (if applicable)
50 | - [ ] Changes have been tested on both Plugin-Mode and Standalone-Mode (if applicable)
51 | - [ ] Statistical accuracy has been verified (for algorithm or optimizer changes)
52 | - [ ] No regression in query plan accuracy compared to InnoDB (if applicable)
53 | - [ ] Performance benchmarks conducted (for performance-sensitive changes)
54 |
55 |
56 | By submitting this PR, you confirm that you've read these guidelines and your changes align with the project's contribution standards.
57 |
58 |
59 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .DS_store
3 | *.iml
4 | .idea/workspace.xml
5 | .vscode
6 | .coverage
7 | __pycache__/
8 | *.pyc
9 | span.log
10 | .DS_Store
11 | output/
12 | *span.log
13 | *nohup.out
14 | *.ipynb
15 | large_data/
16 | *.csv
17 | cache
18 | *.gzip
19 | .lock
20 | *.vscode
21 | *__pycache__/
22 | *.log
23 | *.out
24 | videx.egg-info
25 | tpch_tiny.sql
26 | videx_metadata_tpch_tiny.json
27 | dist
28 | data
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | All notable changes to this project will be documented in this file.
4 |
5 | Including `Added`, `Changed`, `Fixed`, `Deprecated`, `Removed`, `Security`.
6 |
7 | ## [Unreleased]
8 |
9 | ### Added
10 | - refactor videx-server codes, more decoupling with SQLBrain.
11 | - Add a single-stack script to fetch metadata, mirror schema into VIDEX-MySQL, and import metadata into Videx-Server.
12 |
13 | ### Fixed
14 | - fix ndv calculation bugs when ndv information is missing.
15 |
16 | ### Use
17 | - Add an example metadata file based on TPC-H (scale-factor=1) for onboarding.
18 | - provide a simple videx model implementation: `VidexModelExample` for onboarding.
19 |
20 | ## [0.1.0] - 2025-02-12
21 | ### Added
22 | - VIDEX-MySQL plugin
23 | - VIDEX-Server basic code
24 |
25 |
--------------------------------------------------------------------------------
/LICENSE/LICENSE.MIT:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 Bytedance Ltd. and/or its affiliates
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/LICENSES.md:
--------------------------------------------------------------------------------
1 | # Licensing Information
2 |
3 | This project contains software under two different licenses:
4 |
5 | 1. MySQL Engine Implementation
6 | - Licensed under GNU General Public License v2.0
7 | - Located in: src/mysql
8 | - SPDX-License-Identifier: GPL-2.0
9 |
10 | 2. Python Implementation
11 | - Licensed under MIT License
12 | - Located in: all other codes and scripts
13 | - SPDX-License-Identifier: MIT
14 |
15 | ## Notice
16 | - When using or distributing the MySQL engine components, you must comply with GPL-2.0 terms
17 | - The other components can be used under the more permissive MIT license
18 | - If you combine both components, the resulting work must comply with GPL-2.0
19 |
20 | For full license texts, see the LICENSE directory.
--------------------------------------------------------------------------------
/build/Dockerfile.build_env:
--------------------------------------------------------------------------------
1 | # build GCC
2 | FROM debian:bullseye AS gcc-builder
3 | ENV GCC_VERSION=9.3.0
4 | RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
5 | build-essential wget \
6 | libgmp-dev libmpfr-dev libmpc-dev \
7 | && apt-get clean && rm -rf /var/lib/apt/lists/*
8 |
9 | WORKDIR /build
10 | RUN wget https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.gz \
11 | && tar -xf gcc-${GCC_VERSION}.tar.gz \
12 | && cd gcc-${GCC_VERSION} \
13 | && mkdir build && cd build \
14 | && ../configure \
15 | --prefix=/usr/local/gcc-${GCC_VERSION} \
16 | --disable-multilib \
17 | --enable-languages=c,c++ \
18 | --disable-bootstrap \
19 | --disable-nls \
20 | --disable-libsanitizer \
21 | --disable-libvtv \
22 | --disable-libssp \
23 | --disable-libquadmath \
24 | --disable-libgomp \
25 | --disable-libada \
26 | --disable-libstdcxx-pch \
27 | && make -j $(nproc) \
28 | && make install-strip DESTDIR=/gcc-install \
29 | && cd /build && rm -rf *
30 |
31 | # build Bison
32 | FROM debian:bullseye AS bison-builder
33 | ENV BISON_VERSION=3.4.2
34 | RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
35 | build-essential wget \
36 | flex \
37 | m4 \
38 | && apt-get clean && rm -rf /var/lib/apt/lists/*
39 |
40 | WORKDIR /build
41 | RUN wget --no-check-certificate https://ftp.gnu.org/gnu/bison/bison-${BISON_VERSION}.tar.gz \
42 | && tar -xf bison-${BISON_VERSION}.tar.gz \
43 | && cd bison-${BISON_VERSION} \
44 | && ./configure --prefix=/usr/local \
45 | && make -j $(nproc) \
46 | && make install DESTDIR=/bison-install \
47 | && cd /build && rm -rf *
48 |
49 | # final stage
50 | FROM debian:bullseye
51 | COPY --from=gcc-builder /gcc-install/usr/local/gcc-9.3.0 /usr/local/gcc-9.3.0
52 | COPY --from=bison-builder /bison-install/usr/local/bin/bison /usr/local/bin/bison
53 | COPY --from=bison-builder /bison-install/usr/local/lib/liby.* /usr/local/lib/
54 | COPY --from=bison-builder /bison-install/usr/local/share/bison /usr/local/share/bison
55 |
56 | # online required part
57 | RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
58 | cmake \
59 | curl \
60 | python3.9 \
61 | python3.9-dev \
62 | python3.9-venv \
63 | libgmp10 \
64 | libmpfr6 \
65 | libmpc3 \
66 | m4 \
67 | pkg-config \
68 | git \
69 | git-lfs \
70 | libssl-dev \
71 | libreadline-dev \
72 | zlib1g-dev \
73 | libcurl4-openssl-dev \
74 | libldap2-dev \
75 | libsasl2-dev \
76 | libsasl2-modules-gssapi-mit \
77 | libkrb5-dev \
78 | libnuma-dev \
79 | libmecab-dev \
80 | libaio-dev \
81 | libncurses-dev \
82 | libtirpc-dev \
83 | && apt-get clean && rm -rf /var/lib/apt/lists/*
84 |
85 | # 配置 Python 和其他工具
86 | RUN ln -sf /usr/local/gcc-9.3.0/bin/gcc /usr/local/bin/gcc \
87 | && ln -sf /usr/bin/python3.9 /usr/bin/python3 \
88 | && ln -sf /usr/bin/python3.9 /usr/bin/python \
89 | && curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
90 | && python3.9 get-pip.py \
91 | && rm get-pip.py
92 |
93 | # validation
94 | RUN gcc --version | grep "9.3.0" \
95 | && bison --version \
96 | && curl --version | grep "curl" \
97 | && python3.9 --version | grep "3.9" \
98 | && cmake --version | grep "cmake version" \
99 | && echo "All version checks passed!"
100 |
101 | ENV PATH=/usr/local/gcc-9.3.0/bin:/opt/tiger/typhoon-blade:/opt/common_tools:$PATH
102 | ENV LD_LIBRARY_PATH=/usr/local/gcc-9.3.0/lib64
--------------------------------------------------------------------------------
/build/Dockerfile.videx:
--------------------------------------------------------------------------------
1 | # Build MySQL
2 | FROM videx_build:latest AS builder
3 |
4 | WORKDIR /root
5 |
6 | # copy MySQL source files
7 | COPY mysql_server /root/mysql_server
8 | COPY videx_server/build/config.sh /root/videx_server/build/
9 | COPY videx_server/src/mysql/videx /root/videx_server/src/mysql/videx
10 | COPY videx_server/build/build.sh /root/videx_server/build/
11 |
12 | # build
13 | WORKDIR /root/videx_server/build
14 | RUN chmod +x *.sh && \
15 | ./build.sh
16 |
17 | # collect dependency
18 | RUN mkdir -p /root/mysql_server/mysql_build_output/lib64 && \
19 | cp /usr/local/gcc-9.3.0/lib64/libstdc++.so* /root/mysql_server/mysql_build_output/lib64/ && \
20 | cp /usr/local/gcc-9.3.0/lib64/libgcc_s.so* /root/mysql_server/mysql_build_output/lib64/
21 |
22 | # Build final
23 | FROM videx_build:latest
24 |
25 | WORKDIR /root
26 |
27 | COPY --from=builder /root/mysql_server/mysql_build_output /root/mysql_server/mysql_build_output
28 | COPY videx_server /root/videx_server
29 |
30 | WORKDIR /root/videx_server/build
31 |
32 | RUN chmod +x *.sh
33 |
34 | RUN ./init_server.sh
35 |
36 | EXPOSE 13308 5001
37 |
38 | CMD ["./start_server.sh"]
--------------------------------------------------------------------------------
/build/build.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3 | source "${SCRIPT_DIR}/config.sh"
4 |
5 | # Error handling
6 | set -e # Exit on error
7 | set -x # Print commands for debugging
8 |
9 | if [ -d "$MYSQL_HOME/storage/videx" ]; then
10 | echo "Deleting existing $MYSQL_HOME/storage/videx directory..."
11 | rm -rf "$MYSQL_HOME/storage/videx"
12 | fi
13 |
14 | echo "Copying $VIDEX_HOME/src/mysql/videx to $MYSQL_HOME/storage..."
15 | cp -r "$VIDEX_HOME/src/mysql/videx" "$MYSQL_HOME/storage"
16 |
17 | BOOST_DIR=$MYSQL_HOME/boost
18 |
19 | # Clean previous build if exists
20 | if [ -d "$MYSQL_BUILD_DIR" ]; then
21 | echo "Cleaning previous build directory..."
22 | rm -rf "$MYSQL_BUILD_DIR"
23 | fi
24 |
25 | # Create necessary directories
26 | mkdir -p "$BOOST_DIR"
27 | mkdir -p "$MYSQL_BUILD_DIR"/{etc,build,lib64}
28 |
29 | # Change to MySQL source directory
30 | cd "$MYSQL_BUILD_DIR"
31 |
32 | # Configure MySQL build with CMake
33 | # -DWITH_DEBUG=OFF: Disable debug build
34 | # -DCMAKE_BUILD_TYPE=Release: Build release version
35 | # -DBUILD_CONFIG=mysql_release: Use release configuration
36 | # -DFEATURE_SET=community: Build community edition
37 | # -DCMAKE_INSTALL_PREFIX: Set installation directory
38 | # -DMYSQL_DATADIR: Set data directory
39 | # -DSYSCONFDIR: Set configuration directory
40 | # -DWITH_BOOST: Specify boost directory
41 | # -DDOWNLOAD_BOOST: Automatically download boost if needed
42 | cmake .. \
43 | -B./build \
44 | -DWITH_DEBUG=OFF \
45 | -DCMAKE_BUILD_TYPE=Release \
46 | -DBUILD_CONFIG=mysql_release \
47 | -DFEATURE_SET=community \
48 | -DCMAKE_INSTALL_PREFIX=. \
49 | -DMYSQL_DATADIR=./data \
50 | -DSYSCONFDIR=./etc \
51 | -DWITH_BOOST="$BOOST_DIR" \
52 | -DDOWNLOAD_BOOST=ON \
53 | -DWITH_ROCKSDB=OFF \
54 | -DDOWNLOAD_BOOST_TIMEOUT=3600 \
55 | -DWITH_VIDEX_STORAGE_ENGINE=1
56 |
57 | # Build MySQL server (mysqld)
58 | echo "Building MySQL server..."
59 | cmake --build build --target mysqld -- -j "$(nproc)"
60 |
61 | # Build MySQL client
62 | echo "Building MySQL client..."
63 | cmake --build build --target mysql -- -j "$(nproc)"
64 |
65 | # build videx
66 | cmake --build build --target videx -- -j "$(nproc)"
67 |
68 | # Check if build was successful
69 | if [ ! -f "build/runtime_output_directory/mysqld" ]; then
70 | echo "Error: MySQL server build failed!"
71 | exit 1
72 | fi
73 |
74 | if [ ! -f "build/runtime_output_directory/mysql" ]; then
75 | echo "Error: MySQL client build failed!"
76 | exit 1
77 | fi
78 |
79 | # Copy necessary libraries and scripts
80 | echo "Copying libraries and scripts..."
81 | # cp /usr/local/gcc-9.3.0/lib64/* "$MYSQL_BUILD_DIR/lib64/"
82 | # cp ../build/scripts/* "$MYSQL_BUILD_DIR/"
83 |
84 | # Add MySQL and mysqld to PATH environment variable
85 | echo "Adding MySQL client and server to PATH..."
86 | MYSQL_BIN_DIR="$MYSQL_BUILD_DIR/build/runtime_output_directory/"
87 |
88 | if [ -d "$MYSQL_BIN_DIR" ]; then
89 | export PATH="$MYSQL_BIN_DIR:$PATH"
90 | echo "export PATH=\"$MYSQL_BIN_DIR:\$PATH\"" >> ~/.bashrc
91 | echo "MySQL binaries added to PATH. Please restart your shell or run 'source ~/.bashrc' to apply."
92 | else
93 | echo "Error: MySQL binary directory not found! Ensure the build was successful."
94 | exit 1
95 | fi
96 |
97 | echo "MySQL build completed successfully!"
98 | echo "Build directory: $MYSQL_BUILD_DIR"
--------------------------------------------------------------------------------
/build/build_videx.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3 | source "${SCRIPT_DIR}/config.sh"
4 |
5 | # Error handling
6 | set -e # Exit on error
7 | set -x # Print commands for debugging
8 |
9 | if [ -d "$MYSQL_HOME/storage/videx" ]; then
10 | echo "Deleting existing $MYSQL_HOME/storage/videx directory..."
11 | rm -rf "$MYSQL_HOME/storage/videx"
12 | fi
13 |
14 | echo "Copying $VIDEX_HOME/src/mysql/videx to $MYSQL_HOME/storage..."
15 | cp -r "$VIDEX_HOME/src/mysql/videx" "$MYSQL_HOME/storage"
16 |
17 | BOOST_DIR=$MYSQL_HOME/boost
18 |
19 | # Clean previous build
20 | if [ -d "$MYSQL_BUILD_DIR" ]; then
21 | echo "Cleaning previous build directory..."
22 | rm -rf "$MYSQL_BUILD_DIR"
23 | fi
24 |
25 | # Create necessary directories
26 | mkdir -p "$BOOST_DIR"
27 | mkdir -p "$MYSQL_BUILD_DIR"/{etc,build,lib64}
28 |
29 | # Change to MySQL source directory
30 | cd "$MYSQL_BUILD_DIR"
31 |
32 |
33 | cmake .. \
34 | -B./build \
35 | -DWITH_DEBUG=OFF \
36 | -DCMAKE_BUILD_TYPE=Release \
37 | -DBUILD_CONFIG=mysql_release \
38 | -DFEATURE_SET=community \
39 | -DCMAKE_INSTALL_PREFIX=. \
40 | -DMYSQL_DATADIR=./data \
41 | -DSYSCONFDIR=./etc \
42 | -DWITH_BOOST="$BOOST_DIR" \
43 | -DDOWNLOAD_BOOST=ON \
44 | -DWITH_ROCKSDB=OFF \
45 | -DDOWNLOAD_BOOST_TIMEOUT=3600 \
46 | -DWITH_VIDEX_STORAGE_ENGINE=1 \
47 | -DPLUGIN_VIDEX=DYNAMIC
48 |
49 | echo "Building MySQL server..."
50 | cmake --build build --target videx -- -j "$(nproc)"
51 |
--------------------------------------------------------------------------------
/build/config.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Global configurations
3 | export MYSQL_HOME=/root/mysql_server
4 | export VIDEX_HOME=/root/videx_server
5 | export MYSQL_BUILD_DIR=$MYSQL_HOME/mysql_build_output
6 | export MYSQL_PORT=13308
7 | export VIDEX_PORT=5001
8 | export LD_LIBRARY_PATH=$MYSQL_BUILD_DIR/lib64:$MYSQL_BUILD_DIR/build/plugin_output_directory:$MYSQL_BUILD_DIR/build/library_output_directory:$LD_LIBRARY_PATH
9 | export MYSQL_LOG=/var/log/mysql.log
10 | export VIDEX_LOG=/var/log/videx.log
11 |
--------------------------------------------------------------------------------
/build/init_server.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4 | source "${SCRIPT_DIR}/config.sh"
5 |
6 | set -e
7 | set -x
8 | # Copy configuration file
9 | if [ -f "$SCRIPT_DIR/my.cnf" ]; then
10 | cp "$SCRIPT_DIR/my.cnf" "$MYSQL_BUILD_DIR/etc/my.cnf"
11 | else
12 | echo "Warning: my.cnf not found!"
13 | exit 1
14 | fi
15 |
16 | [ ! -d "$MYSQL_BUILD_DIR" ] && echo "MySQL build directory not found!" && exit 1
17 | [ ! -f "$MYSQL_BUILD_DIR/etc/my.cnf" ] && echo "my.cnf not found!" && exit 1
18 |
19 | cd $MYSQL_BUILD_DIR
20 |
21 | # Clean previous build if exists
22 | if [ -d ./data ]; then
23 | echo "Cleaning data..."
24 | rm -rf ./data
25 | fi
26 |
27 | mkdir -p ./data
28 | mkdir -p ./log
29 |
30 |
31 | echo "Starting initialization process..." > $MYSQL_LOG
32 |
33 | ./build/runtime_output_directory/mysqld --defaults-file=./etc/my.cnf --initialize-insecure --user=root --basedir="$MYSQL_BUILD_DIR" --datadir=./data || exit 1
34 |
35 |
36 | # 启动 MySQL 服务
37 | echo "Starting MySQL server..."
38 | ./build/runtime_output_directory/mysqld --defaults-file=./etc/my.cnf --user=root --basedir="$MYSQL_BUILD_DIR" --datadir=./data --socket=./mysql_80.sock --port=$MYSQL_PORT &
39 | MYSQL_PID=$! # 获取 MySQL 进程的 PID
40 |
41 | # 等待 MySQL 服务启动完成
42 | echo "Waiting for MySQL to be ready..."
43 | for i in {1..30}; do
44 | ./build/runtime_output_directory/mysql -h127.0.0.1 -uroot -P$MYSQL_PORT -e "SELECT 1" && break
45 | sleep 2
46 | done
47 |
48 | # 检查 MySQL 是否启动成功
49 | if ! ./build/runtime_output_directory/mysql -h127.0.0.1 -uroot -P$MYSQL_PORT -e "SELECT 1"; then
50 | echo "MySQL failed to start."
51 | kill $MYSQL_PID
52 | exit 1
53 | fi
54 |
55 | # 创建用户 videx
56 | echo "Creating user videx..."
57 | echo "CREATE USER 'videx'@'%' IDENTIFIED WITH mysql_native_password BY 'password'; GRANT ALL ON *.* TO 'videx'@'%'; FLUSH PRIVILEGES;" | \
58 | ./build/runtime_output_directory/mysql -h127.0.0.1 -uroot -P$MYSQL_PORT
59 |
60 | if [ $? -eq 0 ]; then
61 | echo "User videx created successfully"
62 | else
63 | echo "Failed to create user videx!"
64 | kill $MYSQL_PID
65 | exit 1
66 | fi
67 |
68 | # 直接杀死 MySQL 进程
69 | echo "Shutting down MySQL server..."
70 | kill $MYSQL_PID
71 |
72 | # 确保进程被成功终止
73 | for i in {1..10}; do
74 | if ps -p $MYSQL_PID > /dev/null; then
75 | echo "Waiting for MySQL to shut down..."
76 | sleep 1
77 | else
78 | echo "MySQL server stopped successfully."
79 | break
80 | fi
81 | done
82 |
83 | # 如果进程仍未停止,强制杀死
84 | if ps -p $MYSQL_PID > /dev/null; then
85 | echo "MySQL did not shut down gracefully. Forcing termination..."
86 | kill -9 $MYSQL_PID
87 | fi
88 |
89 | echo "Starting initialization videx..." >> $VIDEX_LOG
90 | cd $VIDEX_HOME
91 | python3.9 -m pip install -e . --use-pep517 >> $VIDEX_LOG
92 |
--------------------------------------------------------------------------------
/build/my.cnf:
--------------------------------------------------------------------------------
1 | [mysqld]
2 | port= 13308
3 | socket=mysql_80.sock
4 | innodb_file_per_table=1
5 | optimizer_trace='enabled=on'
6 | optimizer_trace_max_mem_size=4294967295
7 | optimizer_switch=subquery_to_derived=on
8 |
9 | sql_mode = NO_ENGINE_SUBSTITUTION
10 | skip_ssl = 1
11 |
--------------------------------------------------------------------------------
/build/start_server.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3 | source "${SCRIPT_DIR}/config.sh"
4 |
5 |
6 | # Unset proxy environment variables to avoid interference
7 | unset http_proxy HTTP_PROXY
8 | unset https_proxy HTTPS_PROXY
9 | unset no_proxy NO_PROXY
10 | unset all_proxy ALL_PROXY
11 | unset ftp_proxy FTP_PROXY
12 |
13 | cd $MYSQL_BUILD_DIR
14 | echo "Starting MySQL..." >> $MYSQL_LOG
15 | build/runtime_output_directory/mysqld --defaults-file=$MYSQL_BUILD_DIR/etc/my.cnf --user=root --basedir=$MYSQL_BUILD_DIR --datadir=$MYSQL_BUILD_DIR/data >> $MYSQL_LOG 2>&1 &
16 |
17 | echo "Starting videx_server..." >> $VIDEX_LOG
18 |
19 | echo $VIDEX_HOME/src/sub_platforms/sql_opt/videx/scripts
20 | cd $VIDEX_HOME/src/sub_platforms/sql_opt/videx/scripts
21 | echo "Starting Videx server on port 5001..." >> $VIDEX_LOG
22 | python3.9 start_videx_server.py --port 5001 >> $VIDEX_LOG 2>&1 &
23 |
24 | tail -f $VIDEX_LOG
--------------------------------------------------------------------------------
/data/tpch_sf1/explain_tpch_sf1_q21_innodb.json:
--------------------------------------------------------------------------------
1 | {
2 | "query_block": {
3 | "select_id": 1,
4 | "cost_info": {
5 | "query_cost": "1291730.72"
6 | },
7 | "ordering_operation": {
8 | "using_filesort": true,
9 | "grouping_operation": {
10 | "using_temporary_table": true,
11 | "using_filesort": false,
12 | "nested_loop": [
13 | {
14 | "table": {
15 | "table_name": "orders",
16 | "access_type": "ALL",
17 | "possible_keys": [
18 | "PRIMARY"
19 | ],
20 | "rows_examined_per_scan": 1492893,
21 | "rows_produced_per_join": 149289,
22 | "filtered": "10.00",
23 | "cost_info": {
24 | "read_cost": "146692.37",
25 | "eval_cost": "14928.93",
26 | "prefix_cost": "161621.30",
27 | "data_read_per_join": "67M"
28 | },
29 | "used_columns": [
30 | "O_ORDERKEY",
31 | "O_ORDERSTATUS"
32 | ],
33 | "attached_condition": "(`tpch_sf1`.`orders`.`O_ORDERSTATUS` = 'F')"
34 | }
35 | },
36 | {
37 | "table": {
38 | "table_name": "l1",
39 | "access_type": "ref",
40 | "possible_keys": [
41 | "LINEITEM_UK1",
42 | "LINEITEM_FK1"
43 | ],
44 | "key": "LINEITEM_FK1",
45 | "used_key_parts": [
46 | "L_ORDERKEY"
47 | ],
48 | "key_length": "4",
49 | "ref": [
50 | "tpch_sf1.orders.O_ORDERKEY"
51 | ],
52 | "rows_examined_per_scan": 3,
53 | "rows_produced_per_join": 192671,
54 | "filtered": "33.33",
55 | "cost_info": {
56 | "read_cost": "578073.02",
57 | "eval_cost": "19267.17",
58 | "prefix_cost": "797501.62",
59 | "data_read_per_join": "70M"
60 | },
61 | "used_columns": [
62 | "L_ORDERKEY",
63 | "L_SUPPKEY",
64 | "L_COMMITDATE",
65 | "L_RECEIPTDATE",
66 | "L_ID"
67 | ],
68 | "attached_condition": "(`tpch_sf1`.`l1`.`L_RECEIPTDATE` > `tpch_sf1`.`l1`.`L_COMMITDATE`)"
69 | }
70 | },
71 | {
72 | "table": {
73 | "table_name": "nation",
74 | "access_type": "ALL",
75 | "possible_keys": [
76 | "PRIMARY"
77 | ],
78 | "rows_examined_per_scan": 25,
79 | "rows_produced_per_join": 481679,
80 | "filtered": "10.00",
81 | "using_join_buffer": "hash join",
82 | "cost_info": {
83 | "read_cost": "55.80",
84 | "eval_cost": "48167.93",
85 | "prefix_cost": "845725.36",
86 | "data_read_per_join": "330M"
87 | },
88 | "used_columns": [
89 | "N_NATIONKEY",
90 | "N_NAME"
91 | ],
92 | "attached_condition": "(`tpch_sf1`.`nation`.`N_NAME` = 'IRAQ')"
93 | }
94 | },
95 | {
96 | "table": {
97 | "table_name": "supplier",
98 | "access_type": "eq_ref",
99 | "possible_keys": [
100 | "PRIMARY",
101 | "SUPPLIER_FK1",
102 | "idx_S_NATIONKEY_S_SUPPKEY_S_NAME"
103 | ],
104 | "key": "PRIMARY",
105 | "used_key_parts": [
106 | "S_SUPPKEY"
107 | ],
108 | "key_length": "4",
109 | "ref": [
110 | "tpch_sf1.l1.L_SUPPKEY"
111 | ],
112 | "rows_examined_per_scan": 1,
113 | "rows_produced_per_join": 24083,
114 | "filtered": "5.00",
115 | "cost_info": {
116 | "read_cost": "192671.73",
117 | "eval_cost": "2408.40",
118 | "prefix_cost": "1086565.03",
119 | "data_read_per_join": "17M"
120 | },
121 | "used_columns": [
122 | "S_SUPPKEY",
123 | "S_NAME",
124 | "S_NATIONKEY"
125 | ],
126 | "attached_condition": "(`tpch_sf1`.`supplier`.`S_NATIONKEY` = `tpch_sf1`.`nation`.`N_NATIONKEY`)"
127 | }
128 | },
129 | {
130 | "table": {
131 | "table_name": "l2",
132 | "access_type": "ref",
133 | "possible_keys": [
134 | "LINEITEM_UK1",
135 | "LINEITEM_FK1"
136 | ],
137 | "key": "LINEITEM_FK1",
138 | "used_key_parts": [
139 | "L_ORDERKEY"
140 | ],
141 | "key_length": "4",
142 | "ref": [
143 | "tpch_sf1.orders.O_ORDERKEY"
144 | ],
145 | "rows_examined_per_scan": 3,
146 | "rows_produced_per_join": 24083,
147 | "filtered": "90.00",
148 | "first_match": "supplier",
149 | "cost_info": {
150 | "read_cost": "93257.14",
151 | "eval_cost": "2408.40",
152 | "prefix_cost": "1189147.88",
153 | "data_read_per_join": "8M"
154 | },
155 | "used_columns": [
156 | "L_ORDERKEY",
157 | "L_SUPPKEY",
158 | "L_ID"
159 | ],
160 | "attached_condition": "(`tpch_sf1`.`l2`.`L_SUPPKEY` <> `tpch_sf1`.`l1`.`L_SUPPKEY`)"
161 | }
162 | },
163 | {
164 | "table": {
165 | "table_name": "l3",
166 | "access_type": "ref",
167 | "possible_keys": [
168 | "LINEITEM_UK1",
169 | "LINEITEM_FK1"
170 | ],
171 | "key": "LINEITEM_FK1",
172 | "used_key_parts": [
173 | "L_ORDERKEY"
174 | ],
175 | "key_length": "4",
176 | "ref": [
177 | "tpch_sf1.orders.O_ORDERKEY"
178 | ],
179 | "rows_examined_per_scan": 3,
180 | "rows_produced_per_join": 24083,
181 | "filtered": "100.00",
182 | "not_exists": true,
183 | "cost_info": {
184 | "read_cost": "93257.14",
185 | "eval_cost": "2408.40",
186 | "prefix_cost": "1291730.73",
187 | "data_read_per_join": "8M"
188 | },
189 | "used_columns": [
190 | "L_ORDERKEY",
191 | "L_SUPPKEY",
192 | "L_COMMITDATE",
193 | "L_RECEIPTDATE",
194 | "L_ID"
195 | ],
196 | "attached_condition": "(