[PR #1] [MERGED] Load DBLP data once instead of reloading per index config #2

Closed
opened 2026-09-04 00:22:25 +02:00 by Stone_Red · 0 comments
Owner

📋 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: mainHead: claude/quizzical-haibt-fd6d93


📝 Commits (1)

  • d8a906e Load 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_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


🔄 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>
Stone_Red added the pull-request label 2026-09-04 00:22:25 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sandronator/finetuning_aufgabe4#2