Manager.setup_db previously triggered a full DBLP reload into both PostgreSQL and MariaDB on every test step (~9 reloads/run), even though only PostgreSQL was used. Now data is loaded once via load_data_postgres() and tests just swap indexes via apply_indexes_postgres().
Added reset_postgres(config, reload_data=False) as the entry point. reload_data=True is used after cl-both tests, because CLUSTER physically reorders the table and dropping the index alone does not undo that.
Fixed two latent bugs found while reading the code:
BaseStrategy.run iterated self.queries (a dict) instead of self.queries.items(), which would crash on the unpack.
main.py was missing an execute() call after the Aufgabe 3 cl-both setup, silently skipping that test.
Why
The Strategy pattern itself was fine — the slowness came from re-importing millions of DBLP rows into two databases on every index switch. Loading once and only mutating indexes between tests removes the dominant cost.
Notes for reviewer
MariaDB code in setup.py (create_distribute_maria, setupBoth) is kept untouched but is no longer on the main.py path. The standalone CLI at the bottom of setup.py still works via the (now thin) create_distribute_postgres wrapper.
reload_data=True is set at exactly two places in main.py: entering Aufgabe 2 (nc-publ after cl-both) and entering Aufgabe 4 (no-index after cl-both).
KNOWN_INDEX_NAMES lists the indexes ever created by INDEX_CONFIGS; apply_indexes_postgres drops these with IF EXISTS before re-creating per config.
Test plan
Run python main.py and confirm overall runtime drops substantially (single load + index swaps vs. 9 full reloads).
Confirm each Aufgabe prints two EXPLAIN ANALYZE outputs (query_1 and query_2) — previously the iteration bug would have crashed before printing any.
Confirm Aufgabe 3 now produces three result blocks (no-index, nc-both, cl-both) — the cl-both one was previously skipped.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/sandronator/finetuning_aufgabe4/pull/1
**Author:** [@sandronator](https://github.com/sandronator)
**Created:** 5/26/2026
**Status:** ✅ Merged
**Merged:** 5/26/2026
**Merged by:** [@sandronator](https://github.com/sandronator)
**Base:** `main` ← **Head:** `claude/quizzical-haibt-fd6d93`
---
### 📝 Commits (1)
- [`d8a906e`](https://github.com/sandronator/finetuning_aufgabe4/commit/d8a906e2d46a14d76a227500637f391181325c88) Load DBLP data once instead of reloading per index config
### 📊 Changes
**4 files changed** (+101 additions, -63 deletions)
<details>
<summary>View changed files</summary>
📝 `baseStrategy.py` (+1 -1)
📝 `main.py` (+47 -49)
📝 `manager.py` (+2 -2)
📝 `setup.py` (+51 -11)
</details>
### 📄 Description
## Summary
- `Manager.setup_db` previously triggered a full DBLP reload into **both** PostgreSQL and MariaDB on every test step (~9 reloads/run), even though only PostgreSQL was used. Now data is loaded once via `load_data_postgres()` and tests just swap indexes via `apply_indexes_postgres()`.
- Added `reset_postgres(config, reload_data=False)` as the entry point. `reload_data=True` is used after `cl-both` tests, because `CLUSTER` physically reorders the table and dropping the index alone does not undo that.
- Fixed two latent bugs found while reading the code:
- `BaseStrategy.run` iterated `self.queries` (a dict) instead of `self.queries.items()`, which would crash on the unpack.
- `main.py` was missing an `execute()` call after the Aufgabe 3 `cl-both` setup, silently skipping that test.
## Why
The Strategy pattern itself was fine — the slowness came from re-importing millions of DBLP rows into two databases on every index switch. Loading once and only mutating indexes between tests removes the dominant cost.
## Notes for reviewer
- MariaDB code in `setup.py` (`create_distribute_maria`, `setupBoth`) is kept untouched but is no longer on the `main.py` path. The standalone CLI at the bottom of `setup.py` still works via the (now thin) `create_distribute_postgres` wrapper.
- `reload_data=True` is set at exactly two places in `main.py`: entering Aufgabe 2 (`nc-publ` after `cl-both`) and entering Aufgabe 4 (`no-index` after `cl-both`).
- `KNOWN_INDEX_NAMES` lists the indexes ever created by `INDEX_CONFIGS`; `apply_indexes_postgres` drops these with `IF EXISTS` before re-creating per config.
## Test plan
- [ ] Run `python main.py` and confirm overall runtime drops substantially (single load + index swaps vs. 9 full reloads).
- [ ] Confirm each Aufgabe prints two `EXPLAIN ANALYZE` outputs (`query_1` and `query_2`) — previously the iteration bug would have crashed before printing any.
- [ ] Confirm Aufgabe 3 now produces three result blocks (`no-index`, `nc-both`, `cl-both`) — the `cl-both` one was previously skipped.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/sandronator/finetuning_aufgabe4/pull/1
Author: @sandronator
Created: 5/26/2026
Status: ✅ Merged
Merged: 5/26/2026
Merged by: @sandronator
Base:
main← Head:claude/quizzical-haibt-fd6d93📝 Commits (1)
d8a906eLoad DBLP data once instead of reloading per index config📊 Changes
4 files changed (+101 additions, -63 deletions)
View changed files
📝
baseStrategy.py(+1 -1)📝
main.py(+47 -49)📝
manager.py(+2 -2)📝
setup.py(+51 -11)📄 Description
Summary
Manager.setup_dbpreviously triggered a full DBLP reload into both PostgreSQL and MariaDB on every test step (~9 reloads/run), even though only PostgreSQL was used. Now data is loaded once viaload_data_postgres()and tests just swap indexes viaapply_indexes_postgres().reset_postgres(config, reload_data=False)as the entry point.reload_data=Trueis used aftercl-bothtests, becauseCLUSTERphysically reorders the table and dropping the index alone does not undo that.BaseStrategy.runiteratedself.queries(a dict) instead ofself.queries.items(), which would crash on the unpack.main.pywas missing anexecute()call after the Aufgabe 3cl-bothsetup, silently skipping that test.Why
The Strategy pattern itself was fine — the slowness came from re-importing millions of DBLP rows into two databases on every index switch. Loading once and only mutating indexes between tests removes the dominant cost.
Notes for reviewer
setup.py(create_distribute_maria,setupBoth) is kept untouched but is no longer on themain.pypath. The standalone CLI at the bottom ofsetup.pystill works via the (now thin)create_distribute_postgreswrapper.reload_data=Trueis set at exactly two places inmain.py: entering Aufgabe 2 (nc-publaftercl-both) and entering Aufgabe 4 (no-indexaftercl-both).KNOWN_INDEX_NAMESlists the indexes ever created byINDEX_CONFIGS;apply_indexes_postgresdrops these withIF EXISTSbefore re-creating per config.Test plan
python main.pyand confirm overall runtime drops substantially (single load + index swaps vs. 9 full reloads).EXPLAIN ANALYZEoutputs (query_1andquery_2) — previously the iteration bug would have crashed before printing any.no-index,nc-both,cl-both) — thecl-bothone was previously skipped.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.