Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
7db8cfa
Add antlr+llvm template
stewkk Oct 30, 2025
39d4db6
Add postgresql grammar
stewkk Oct 30, 2025
806c6b3
Upgrade C++ standard
stewkk Oct 30, 2025
105b986
Add build with sanitizers
stewkk Oct 30, 2025
fdcd843
Add library target
stewkk Nov 1, 2025
4c901fb
Impl getting ast from antlr
stewkk Nov 12, 2025
8c86456
Impl parsing simple select statement
stewkk Nov 12, 2025
a6829ac
Support select statement with single column output
stewkk Nov 14, 2025
c366e9f
Support multiple columns projection in select stmt
stewkk Nov 14, 2025
88f896b
Support where clause
stewkk Nov 18, 2025
cc3366c
Change attributes list to be pair (table, column)
stewkk Nov 20, 2025
2b62495
Refactor
stewkk Nov 26, 2025
93565fa
Add basic error handling
stewkk Nov 26, 2025
51eac13
Improve error handling
stewkk Nov 26, 2025
d8e1e4f
Report unsupported statements
stewkk Nov 26, 2025
550fb6b
Add empty query test
stewkk Nov 26, 2025
1d0f363
Implement proper handling of selectstmt
stewkk Nov 27, 2025
6492b8b
Implement arbitrary expressions parsing
stewkk Dec 3, 2025
aadaaef
Add bool expression test
stewkk Dec 3, 2025
57a8ca7
Refactor
stewkk Dec 3, 2025
f0a259c
Impl cross joins
stewkk Dec 9, 2025
99c57fd
Impl outer joins
stewkk Dec 9, 2025
3495310
Impl simple select execution
stewkk Dec 14, 2025
5881a63
Impl seq_scan for more than 10 tuples
stewkk Dec 16, 2025
73b196a
Add parallelizm test
stewkk Dec 16, 2025
0b9dba8
Impl projection execution
stewkk Dec 16, 2025
61f0cc6
Impl filter
stewkk Dec 18, 2025
1ea65e6
Impl cross join
stewkk Dec 18, 2025
37fc077
Impl inner join
stewkk Dec 19, 2025
2bcf4f7
Impl left join
stewkk Dec 19, 2025
582a8a4
Add right join test
stewkk Dec 19, 2025
4688566
Refactor
stewkk Dec 20, 2025
aaef50b
Add llvm jit
stewkk Dec 20, 2025
e5d6813
Impl basic benchmark
stewkk Jan 9, 2026
77f844d
Impl benchmarks
stewkk Jan 9, 2026
eb2b51d
Fix complex query
stewkk Jan 9, 2026
561f6e3
Add more benchmarks
stewkk Jan 10, 2026
5d51dc2
Add benchmarks analysis
stewkk Jan 10, 2026
e348076
Add report
stewkk Jan 10, 2026
f467034
Done report
stewkk Jan 18, 2026
32db3ae
Fix
stewkk Jan 19, 2026
16efa22
Fix speedup
stewkk Feb 4, 2026
53d53d9
Fix report
stewkk Feb 5, 2026
a37989a
Fix typo
stewkk Feb 6, 2026
f86a621
Add presentation
stewkk Feb 7, 2026
7e42bad
Link llvm dynamicly & implement memo popultaion
stewkk Apr 18, 2026
893e292
Impl search algorithm
stewkk Apr 19, 2026
8fe07e4
Refactoring
stewkk Apr 19, 2026
1495fe3
Refactoring
stewkk Apr 19, 2026
d2d6074
Implement RulesApplier
stewkk Apr 19, 2026
28cec90
Add deduptication in Memo
stewkk Apr 19, 2026
a62c354
Impl Memo population
stewkk Apr 19, 2026
c1657a7
Impl implementation rules handling in RulesApplier
stewkk Apr 19, 2026
2028669
Refactor
stewkk Apr 20, 2026
6f6c199
Update flake
stewkk Apr 20, 2026
8898de9
Add limit passing
stewkk Apr 22, 2026
3d99858
Implement branch & bound
stewkk Apr 23, 2026
ecdcca7
Add report wip
stewkk Apr 30, 2026
93ae089
wip
stewkk May 2, 2026
ea46c0e
Add pdf
stewkk May 4, 2026
ca605f4
Wip
stewkk May 5, 2026
030283d
Wip
stewkk May 6, 2026
8833c04
Wip
stewkk May 6, 2026
0683888
Done
stewkk May 6, 2026
470d60e
Fix
stewkk May 7, 2026
d27e517
Impl building optimal plan
stewkk May 9, 2026
095da0a
Impl plan serializer
stewkk May 9, 2026
af7fe0d
Impl execution of physical plan
stewkk May 11, 2026
5708c10
Add test
stewkk May 11, 2026
aadd497
Fix review issues
stewkk May 11, 2026
d164eaa
Fix
stewkk May 11, 2026
456171f
Fix
stewkk May 11, 2026
ca548b3
Add example
stewkk May 11, 2026
bb99b46
Fix
stewkk May 11, 2026
dae5cac
Fix
stewkk May 11, 2026
2795f12
Fix
stewkk May 11, 2026
3c571b9
Fix
stewkk May 11, 2026
38c53e9
Add todos
stewkk May 11, 2026
84bea1f
Refactor
stewkk May 11, 2026
847b183
Refactor, add debug logs, fix bug
stewkk May 11, 2026
0ede4e0
Fix
stewkk May 13, 2026
6c2d5f0
Add lazy loading of dataset
stewkk May 20, 2026
6b292d7
Add missing physical ops
stewkk May 20, 2026
d4df2e5
Implement converter
stewkk May 20, 2026
3157f2e
Add simple random query generator
stewkk May 20, 2026
6611f4f
Impl reachability check
stewkk May 21, 2026
89f826f
Add sort order property
stewkk May 22, 2026
51fdf3b
Add sort operator
stewkk May 22, 2026
c1e55d1
Impl sort by support in optimizer
stewkk May 22, 2026
25d1c21
Fix use after free
stewkk May 24, 2026
618a2c5
Refactor
stewkk May 24, 2026
bfff9d9
Refactor
stewkk May 24, 2026
8e827c3
Add ORDER BY support to parser
stewkk May 24, 2026
0c158bd
wip: needs review
stewkk May 25, 2026
0e99fd9
wip: hash join support, needs review
stewkk May 25, 2026
0ed6290
Impl fuzzing, fix bugs
stewkk May 27, 2026
0ead6f9
Add some rules
stewkk May 27, 2026
7400561
Add reachability fuzzer
stewkk May 27, 2026
30abea0
Fix bug in jit
stewkk May 29, 2026
2d00045
Add SBB benchmark
stewkk May 29, 2026
27111a9
Add strings support
stewkk May 29, 2026
950a8d5
Impl IN and BETWEEN support
stewkk May 29, 2026
fd68c68
Impl group by
stewkk May 29, 2026
03859f3
Add SBB benchmark
stewkk May 29, 2026
809b8c8
Support GROUP BY in fuzzers
stewkk May 30, 2026
0963a8d
Fix
stewkk May 30, 2026
1f2d8a8
Add dot visualization of plans
stewkk May 30, 2026
c5c9a32
Dump plans to disk
stewkk May 30, 2026
db36607
Output only on diffs
stewkk May 30, 2026
7fc9bb3
Fix
stewkk May 30, 2026
071018d
wip
stewkk May 30, 2026
5ab09a3
Update ssb-dbgen
stewkk May 30, 2026
031fe24
Add physical operator cost proof benchmarks
stewkk May 30, 2026
07e6a03
Plot benchmarks
stewkk May 30, 2026
cd2e6a8
Update coefficients
stewkk May 31, 2026
3ea373e
Fix
stewkk Jun 1, 2026
5d0e601
Add converted notebook
stewkk Jun 1, 2026
8bbd772
Add practice report
stewkk Jun 1, 2026
012be6f
Fix segfault
stewkk Jun 1, 2026
081074b
Add more benchmarks
stewkk Jun 1, 2026
53b7421
Add cost to runtime comparison on random queries
stewkk Jun 1, 2026
aa7cec6
Fix
stewkk Jun 1, 2026
2b63f14
Fix
stewkk Jun 2, 2026
299bcd1
Fix
stewkk Jun 2, 2026
3d4a815
Fix
stewkk Jun 2, 2026
7688ae2
Add report draft
stewkk Jun 5, 2026
1de9a98
Intro
stewkk Jun 6, 2026
e2bea7e
Refactor
stewkk Jun 6, 2026
dc80227
Refactor report
stewkk Jun 6, 2026
061024e
wip
stewkk Jun 6, 2026
90f30ec
wip
stewkk Jun 6, 2026
162619b
wip
stewkk Jun 6, 2026
6177f79
wip
stewkk Jun 7, 2026
f7c9fed
Done
stewkk Jun 7, 2026
4ebbc71
wip
stewkk Jun 7, 2026
e72864f
Done
stewkk Jun 7, 2026
d029f0a
Add naive plan cost
stewkk Jun 7, 2026
b482cd6
Add naive plan output
stewkk Jun 7, 2026
09eb82c
Add cost and cardinality to dot graph
stewkk Jun 7, 2026
c1d0eb7
Typo
stewkk Jun 7, 2026
a2ee42e
Index seek support in optimizer
stewkk Jun 7, 2026
0841199
Fix UB
stewkk Jun 7, 2026
16a4f45
Add MergeJoin
stewkk Jun 9, 2026
7cf088e
Add StreamAgg
stewkk Jun 9, 2026
c06be56
Update report and benchmarks
stewkk Jun 9, 2026
e06b6df
Update report
stewkk Jun 9, 2026
ea59a71
Update title
stewkk Jun 9, 2026
07935e1
Fix
stewkk Jun 9, 2026
815e14c
Fix
stewkk Jun 10, 2026
8483013
Done
stewkk Jun 10, 2026
d911f88
Implement remaining transformation rules and support constraints
stewkk Jun 10, 2026
eead31c
Fix
stewkk Jun 14, 2026
1c9a7b7
Fix
stewkk Jun 14, 2026
64b4713
Update
stewkk Jun 14, 2026
906f1ee
Fix
stewkk Jun 14, 2026
369a864
Fix
stewkk Jun 14, 2026
9b26cc5
Fix
stewkk Jun 14, 2026
455b649
Add stats collection
stewkk Jun 15, 2026
fcec0c0
More stats
stewkk Jun 15, 2026
b2a1810
Done?
stewkk Jun 15, 2026
fa35de0
Fix all
stewkk Jun 15, 2026
9d935f9
fix
stewkk Jun 15, 2026
32672f6
typos
stewkk Jun 15, 2026
b834120
typos
stewkk Jun 15, 2026
f861888
Add presentation
stewkk Jun 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
BasedOnStyle: Google
AccessModifierOffset: '-2'
AlignTrailingComments: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AlwaysBreakTemplateDeclarations: 'No'
BreakBeforeBraces: Attach
ColumnLimit: '100'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
IncludeBlocks: Preserve
IndentPPDirectives: AfterHash
IndentWidth: '2'
NamespaceIndentation: None
BreakBeforeBinaryOperators: All
BreakBeforeTernaryOperators: 'true'
...
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/.cache/
/build/
/CMakeFiles/
**/codegen/
/build-sanitizers/
/build-release/
FlameGraph/
/.vscode/
/perf.data
/perf.data.old
**/.auctex-auto/
**/build/
/.odbc/
**/__pycache__
/build-tsan/
/benchmarks/datasets/ssb/generated/
/benchmarks/datasets/ssb/raw/
/.plans/
/report/build-practice/
/report/build-vkr/
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "research/datasets"]
path = research/datasets
url = git@github.com:ronaldbradford/data.git
[submodule "research/imdb-sqlserver"]
path = research/imdb-sqlserver
url = git@github.com:sqlsunday/imdb-to-sqlserver.git
[submodule "research/ssb-dbgen"]
path = research/ssb-dbgen
url = git@github.com:stewkk/ssb-dbgen.git
54 changes: 54 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
cmake_minimum_required(VERSION 3.15..3.29)

project(
sql-compiler
VERSION 0.0.1
LANGUAGES CXX
)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}")

option(SANITIZE_ADDRESS "Enable AddressSanitizer" OFF)
option(SANITIZE_UNDEFINED "Enable UndefinedBehaviorSanitizer" OFF)
option(SANITIZE_THREADS "Enable ThreadSanitizer" OFF)

add_compile_options(-Wno-deprecated-declarations)

if (SANITIZE_ADDRESS)
add_compile_options(-fsanitize=address -fno-omit-frame-pointer -g)
add_link_options(-fsanitize=address)
endif()

if (SANITIZE_UNDEFINED)
add_compile_options(-fsanitize=undefined -fno-omit-frame-pointer -g)
add_link_options(-fsanitize=undefined)
endif()

if (SANITIZE_THREADS)
add_compile_options(-fsanitize=thread -fno-omit-frame-pointer -g)
add_link_options(-fsanitize=thread)
endif()

if(STEWKK_SQL_DEBUG)
add_definitions(-DSTEWKK_SQL_DEBUG)
endif()

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)

set(FETCHCONTENT_QUIET OFF)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

add_subdirectory(src/stewkk/sql)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
add_subdirectory(benchmarks)

include(CTest)
if(BUILD_TESTING)
add_subdirectory(test)
endif()
endif()
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
CURRENT_DIR := $(shell pwd)
CODEGEN_DIR := $(CURRENT_DIR)/src/stewkk/sql/logic/parser/codegen
PARSER_SOURCE_DIR := $(CURRENT_DIR)/src/stewkk/sql/logic/parser

build:
cmake --build build -- -j 6

sanitize:
cmake --build build-sanitizers -- -j 8

codegen:
@antlr -Dlanguage=Cpp -visitor -o $(CODEGEN_DIR) -package stewkk::sql::codegen $(PARSER_SOURCE_DIR)/PostgreSQLParser.g4 $(PARSER_SOURCE_DIR)/PostgreSQLLexer.g4

test-ssb-converter:
pytest benchmarks/datasets/ssb

dot:
dot -T png -O .plans/*.dot

.PHONY: codegen build sanitize test-ssb-converter
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
```sh
docker run --rm -it --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword postgres
docker exec -it some-postgres psql -U postgres
```


```sh
git clone https://github.com/brendangregg/FlameGraph.git

sed -i 's|#!/usr/bin/perl -w|#!/usr/bin/env perl|' FlameGraph/stackcollapse-perf.pl
sed -i 's|#!/usr/bin/perl -w|#!/usr/bin/env perl|' FlameGraph/flamegraph.pl

perf record -F 99 -g ./build-release/bin/benchmarks --benchmark_filter="BM_SQL<CachedJitCompiledExpressionExecutor.*"

perf script | FlameGraph/stackcollapse-perf.pl | FlameGraph/flamegraph.pl > benchmarks/flamegraph-jit.svg
```
16 changes: 16 additions & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include(FetchGBenchmark)

add_executable(benchmarks main.cpp operator_cost.cpp)
target_compile_features(benchmarks PRIVATE cxx_std_23)
set_target_properties(benchmarks PROPERTIES
CXX_STANDART 23
CXX_STANDART_REQUIRED YES
CXX_EXTENSIONS YES
)
target_compile_options(benchmarks PRIVATE ${BASE_COMPILE_FLAGS})
target_link_options(benchmarks PRIVATE ${BASE_LINK_FLAGS})
target_link_libraries(benchmarks PRIVATE stewkk::libsql benchmark::benchmark
Boost::asio
Boost::thread
Boost::filesystem
)
Loading