Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce performance issues caused by Build Plan #162

Open
KKould opened this issue Mar 14, 2024 · 3 comments
Open

Reduce performance issues caused by Build Plan #162

KKould opened this issue Mar 14, 2024 · 3 comments
Labels

Comments

@KKould
Copy link
Member

KKould commented Mar 14, 2024

Feature Request

I try to perform this case in a table with 200,000 rows: select * from t1 where c1 > 500 and c1 < 1000, and use pprof-rs to generate a flame graph
flamegraph
The most obvious one is StatisticMetaLoader::load, which will then be cached, and then I generate a flame graph after loading.
flamegraph_no_load_meta
In the new flame graph, HepOptimizer::find_best is a relatively large performance bottleneck.

@KKould KKould changed the title Reduce performance issues caused by BuildPlan Reduce performance issues caused by *Build Plan* Mar 14, 2024
@KKould KKould changed the title Reduce performance issues caused by *Build Plan* Reduce performance issues caused by Build Plan Mar 14, 2024
@KKould KKould added the perf label Mar 14, 2024
@KKould KKould mentioned this issue Mar 22, 2024
9 tasks
@KKould
Copy link
Member Author

KKould commented Mar 28, 2024

2_00_000 row on case: select * from t1 where c1 > 500 and c1 < 1000 2024/3/29

flamegraph

@KKould
Copy link
Member Author

KKould commented Mar 28, 2024

let fnck_sql = DataBaseBuilder::path("./fncksql_bench")
    .build()
    .await?;
let guard = pprof::ProfilerGuard::new(100).unwrap();

for _ in 0..10_000 {
    let _ = fnck_sql.run("select * from t1 where c1 > 500 and c1 < 1000").await?;
}
if let Ok(report) = guard.report().build() {
    let file = File::create("./flamegraph.svg").unwrap();
    report.flamegraph(file).unwrap();
};

@KKould
Copy link
Member Author

KKould commented Mar 30, 2024

I ran the benchmark again, and this pr: #193 made the performance of select * from t1 where c1 = 1000 basically the same as sqlite: sqlite: 20us, fncksql: 27us, but select * from t1 where c1 > 500 and c1 < 1000 is still very different: sqlite: 130us, fncksql: 500us,

FnckSQL: Full  Read by 'select * from t1'
                        time:   [117.76 ms 119.42 ms 121.73 ms]
                        change: [-8.4606% -6.8487% -4.7828%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) high mild

SQLite: Full  Read by 'select * from t1'
                        time:   [39.378 ms 40.132 ms 41.577 ms]
                        change: [-16.732% -14.192% -11.760%] (p = 0.00 < 0.05)
                        Performance has improved.

FnckSQL: Point Read by 'select * from t1 where c1 = 1000'
                        time:   [27.418 µs 27.535 µs 27.640 µs]
                        change: [-15.660% -14.844% -14.174%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) low mild

SQLite: Point Read by 'select * from t1 where c1 = 1000'
                        time:   [20.427 µs 20.501 µs 20.602 µs]
                        change: [-10.885% -10.317% -9.7520%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) high mild

FnckSQL: Range Read by 'select * from t1 where c1 > 500 and c1 < 1000'
                        time:   [499.18 µs 500.34 µs 501.96 µs]
                        change: [-12.385% -11.399% -10.521%] (p = 0.00 < 0.05)
                        Performance has improved.

SQLite: Range Read by 'select * from t1 where c1 > 500 and c1 < 1000'
                        time:   [129.42 µs 129.59 µs 129.80 µs]
                        change: [-7.2815% -6.8357% -6.2602%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) high severe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant