fintual-backend-devops-go / experiments / optimized / README.md
README.md
Raw

Final Django query control

This optional variant changes only the list/search/tag queries. It uses select_related, a field-limited author/post projection, and a field-limited tag prefetch. Original handlers implement the other five endpoints. It does not patch or overwrite blog/ or core/.

From the repository root, run bin/build, bin/reference setup, then bin/optimized. This requires Python 3.14 and uv in addition to the Go and PostgreSQL prerequisites. The default database is the dedicated assignment_harness_django, and the default port is 18000. Do not run the reference server on the same port at the same time.

The same 66-case suite and six full-data response comparisons pass. To reproduce:

harness/harness verify --db 'dbname=assignment_harness_django' \
  --url http://127.0.0.1:18000 --golden fixtures/contract
harness/harness seed --db 'dbname=assignment_harness_django'
harness/harness bench --db 'dbname=assignment_harness_django' \
  --url http://127.0.0.1:18000 --pid MASTER_PID --full \
  --workload posts --requests 3 --repeats 5 --concurrency 1 \
  --output reports/optimized-new-posts.json

Repeat for search and tag. Compare with separately run Go measurements using the same fixture, preparation, request counts and budgets. These short full-response runs do not support a reliable p95 estimate or a production capacity claim.

The query counts are comparable, not every implementation detail. Django still constructs ORM instances and runs its schema/JSON pipeline. Go uses pgx and Go structs. SQL shapes, drivers and serialization differ. This experiment measures an optimized implementation comparison, not an isolated programming-language effect.