dblab

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dblab is DBLab, the data tier of a shop: PostgreSQL tables for customers, products and orders, seeded into a database you give it, and an in-process Redis (miniredis) with a product cache and a popularity ranking. The databases pack runs its queries and commands straight against both; DBLab's own HTTP side only reports health and counts. It is the reference app for the databases pack.

Planted bottlenecks (see README.md), each switched off by a fix flag:

  • index: orders has no index on customer_id, so a customer's order history scans the whole table (fix "index" adds one on (customer_id, created_at)).
  • hotrow: a trigger adds every new order to one running-totals row, so concurrent checkouts queue on that row's lock until each commits (fix "hotrow" spreads the totals over 16 rows by order id).

Index

Constants

View Source
const Schema = "dblab"

Schema is where DBLab's tables live; it is dropped and recreated on every start.

Variables

This section is empty.

Functions

func Open

func Open(cfg labkit.Config) (*labkit.App, error)

Open seeds the PostgreSQL database in cfg.Postgres, starts Redis on cfg.Listen and returns the app.

Types

type Sizes

type Sizes struct{ Customers, Products, Orders int }

Sizes are the seeded row counts.

func Seeded

func Seeded(fast bool) Sizes

Seeded returns the row counts DBLab seeds (smaller with -fast).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL