# DBIx::Fast examples

Start here: **`raw-sql.pl`** — a self-contained tour of running your own SQL
(SELECT return shapes, streaming iterator, raw UPDATE/DDL, named placeholders),
no server needed:

```sh
perl -Ilib examples/raw-sql.pl
```

The rest fall into two families: **live-server demos** (take a DSN argument, or
fall back to the `DBIX_FAST_TEST_*` environment variables that `../dev/test.sh`
exports) and **self-contained benchmarks** (SQLite / pure Perl, no server
needed).

Run everything at once against throwaway docker containers:

```sh
../dev/test.sh examples     # from this directory (or ./dev/test.sh from the root)
```

## Live-server demos

| Script | Shows | Server |
|---|---|---|
| `profiler-mariadb.pl` | query tracker, EXPLAIN, table/index/server stats, connections | MariaDB — also works against MySQL (`mysql://` DSN resolves to `Profile::mysql`) |
| `profiler-pg.pl` | the same tour on PostgreSQL (`Profile::Pg`, `pg_stat_*`) | PostgreSQL |
| `monitor-connections.pl` | one-shot connection monitor; `--watch` refreshes, `--json` emits `DBIx::Fast::Output` events | MariaDB / MySQL |

```sh
perl -Ilib examples/profiler-mariadb.pl mariadb://root:test123@127.0.0.1:3307/dbix_test
perl -Ilib examples/monitor-connections.pl --json    # DSN from DBIX_FAST_TEST_MARIADB
```

## Benchmarks

| Script | Measures |
|---|---|
| `benchmark-statement-cache.pl` | prepare_cached vs raw prepare vs select* convenience calls (`-t SECONDS`, `--mariadb DSN` for a live run) |
| `benchmark-query-cache.pl` | cached() hit/miss cost vs going to SQLite |
| `benchmark-cache-backends.pl` | LRU::Cache vs hash vs CHI backend op cost |
| `benchmark-lazy-require.pl` | startup cost of eager vs lazy subsystem loading |
| `benchmark-profiler-regex.pl` | the profiler's SQL-classification regexes |
