dbForge Data Generator for PostgreSQL earns its license in a narrow but common case: a schema with several related tables, a dataset your team rebuilds on a schedule, and teammates who do not write generation SQL. Configure the project once, pin a seed, and save the .dgen file—every rebuild produces the same shape of data with parent rows landing before children.
generate_series() inside a .sql file, executed with psql -f, is cheaper and diffs cleanly. And when valid data depends on application rules (invoice totals, state machines, derived flags) a Faker script in your app’s language is usually the better fit.
Quick Take
- The saved project is the payoff: parent-before-child ordering and NULL ratios become configuration a teammate can rerun, not tribal knowledge.
- The repeatability lever is seed-based value distribution: repopulating a column reproduces the same values each run.
- Think twice about the truncate-before-generation checkbox. Selected, it permanently deletes every existing row in the target table.
- The real cost is a commercial license plus a learning curve across the wizard’s output, options, scripts, and summary pages.
- If your CI already runs
psql, write the seed as SQL. The committed script is the fixture, and the diff is the review.
Why a tiny hand-written seed set lies about your queries
A handful of rows behave nothing like a production table. PostgreSQL devises a query plan from the query’s structure and the properties of the data, and the statistics behind that decision come from random samples. Estimates shift as the table changes, and they vary by platform. At that size nearly every plan looks cheap, so a sequential scan wins and nobody notices. Load a production-sized table and the same query needs the index you forgot to create, or discovers that a column with one repeated value gives the planner no reason to reach for it.
PostgreSQL indexes make that difference visible: they let the server find specific rows faster than a full sweep, and they add overhead to the database as a whole in exchange. Test data with no skew never shows you which side of that trade-off your schema landed on.
Constraints have the same blind spot. A violation raises an error at write time, so a seed file that runs clean feels like proof. It isn’t. Consider an orders table with CHECK (total_cents > 0). A check constraint passes when the expression evaluates to true or NULL, so a NULL total sails through unless the column is also declared NOT NULL. Seed a handful of rows with a single status value and no nulls, and you have tested neither the check nor the query that filters on it. That NULL behaviour is documented in PostgreSQL’s constraints documentation, and it is an easy trap to fall into.
That is the argument for a generator with schema awareness: it can produce skewed distributions, explicit NULL ratios, and rows that actually satisfy the foreign keys you declared.
What dbForge Studio and its Data Generator actually cover
dbForge Studio for PostgreSQL is Devart’s IDE for PostgreSQL development, operations, analysis and reporting, and test data generation ships inside it as one feature among many. If your team already runs Studio for development or analysis work, you may already own the license you need.
The vendor describes the Data Generator with a set of concrete capabilities: a large predefined generator library, saved generators you can reuse, foreign-key-consistent data across tables, automatic command-line script generation for scheduled runs, and a preview pane that refreshes as you change settings. Those are the vendor’s own claims about its own product, and they are the reason the tool exists. Whether they hold for your schema is something only a trial run on a scratch database will tell you.
The honest limits matter just as much. First, Devart’s dbForge Data Generator for PostgreSQL page publishes a supported-type list: bigint, integer, smallint, numeric, real, date, time, timestamp, character, character varying, text, json, point, polygon and uuid, then adds “and more”. Boolean, bytea, enum and timestamptz are not named. They may well work in your build: check a column before you build a workflow on top of it, and fall back to a custom generator or a post-generation UPDATE where they don’t. Second, a generator draws values; it does not know that orders.total should equal the sum of its line items. Pre- and post-population scripts are the hook for that kind of rule, and so is a Faker harness that already models it.
- What you gain: a GUI where a teammate who doesn’t write SQL can configure a dataset, plus a generated script your DBA can read before it runs.
- What you pay: a commercial license, and a learning curve across the wizard’s output, options, scripts, and summary pages.
- What stays your job: deciding the NULL ratios, the distribution shape, which tables belong in the run, and whether the output is valid for your application.
Before you start: prerequisites and blast radius
Prerequisites
- A target database you are allowed to destroy: a scratch copy or a branch, never a shared staging instance someone else is testing against.
- A backup of anything you care about. Devart’s own setup instructions open by telling you to back up the database before generating.
- The TRUNCATE privilege on every table in the run if you intend to use the truncate option, and an understanding that it locks each table exclusively while it works.
- The schema already deployed: tables, primary keys, foreign keys, enum types, and any CHECK constraints you want the data to exercise.
- dbForge Studio installed with a working connection to that database, or the free trial if you are still evaluating.
- Your PostgreSQL and operating-system versions checked against the vendor’s current system requirements.
- A version-controlled home for both the
.dgenproject file and the generated SQL script, so the next person inherits configuration instead of folklore.
Run the twelve-step project setup end to end
The sequence below follows Devart’s documented Data Generator setup flow, with the decisions that matter for a PostgreSQL schema called out at each stage. Run it against a scratch database the first time.
- Open a new data generation project.In the top menu, choose Database > Tasks > New Data Generation. You can also right-click the server connection or database in Database Explorer and pick Tasks > New Data Generation from the context menu.
The feature is Devart’s dbForge Data Generator for PostgreSQL inside Studio, so you need a Studio connection that can already see the target schema. If the menu item is greyed out, fix the connection first.
The Data Generator Project Properties dialog should open with a Connection page showing your existing connections.
- Point it at the right connection and database.Select the connection and the target database on the Connection page. To create a new one, click Manage in the Connection dropdown, then New in the Connection Manager dialog.
This dropdown is your last cheap chance to catch a wrong host. Read the database name twice; the destructive options later in the wizard act on whatever is selected here.
The page should now show the database you intend to populate, with no pending connection errors.
- Set row distribution and decide about truncate.Three row-distribution modes control volume: a specified number of rows, a proportion of the existing data, or generation over a time period per table. Pick the one that matches how you think about the dataset: a fixed count for a fixture, a proportion when the dataset should be sized relative to the existing table.
The truncate option is the dangerous one. Selected, the table is truncated and all existing rows are permanently deleted. Cleared, new data is appended to what is already there. Underneath, that is PostgreSQL’s TRUNCATE: it takes an ACCESS EXCLUSIVE lock that blocks every other operation on the table, needs the TRUNCATE privilege, and refuses to run when tables that reference the target are not included in the same command. CASCADE lifts that restriction by truncating the referencing tables too, which is rarely what you meant.
Confirm the checkbox state before you move on: it is a single tick with no undo outside a transaction.
- Choose seed-based or fresh-random value distribution.Value distribution decides whether repopulating a column produces the same values again. The seed mode generates values from a specified seed and reproduces the same set of values each time. The random mode produces new numbers on every run.
Use a seed for anything you will rerun, diff, or hand to a colleague: it turns “some test data” into a fixture you can reason about across machines.
If you need two runs to match later, note the seed value somewhere in the project’s README.
- Save the project file.Save the data generation project with the
.dgenextension so you can reopen and rerun it later. That file holds the configuration (tables, columns, distribution modes, NULL ratios) and it is the artefact that makes the workflow repeatable.Store it beside your migrations. A project file under version control answers the question “how did we build staging data last quarter” without an archaeologist.
Studio should return to the main data generation window with the project open and the Tables and columns pane visible.
- Select tables and columns.In the Tables and columns to populate pane, tick the tables you need and, inside each, the columns that matter.
Generating fewer columns keeps the script shorter and the review faster. If a downstream query needs
created_at, generate it; if nothing readsinternal_notes, leave it out.The pane should now show your selected tables with children visible under each.
- Configure table settings and resolve foreign-key parents.Select a table and set its generation settings. If a column in that table carries a foreign key to a table you excluded, generation will fail on the reference. The fix is in the Table generation settings pane: open Related tables and include or exclude the related parent and child tables as needed.
The failure surfaces as a foreign-key problem, so fix it in Related tables rather than hunting for a missing-table error.
Repeat for every table in the run, then confirm each parent appears in the generation set before any child that references it.
- Configure the columns that carry judgment calls.Per-column settings include the percentage of NULL values to generate, the percentage of empty values, a unique-value setting, and country-specific data conventions.
Set the NULL percentage deliberately on columns your queries probe with
IS NULL,COALESCE, orNOT IN. A boolean column has three states, andWHERE NOT activequietly skips the NULL rows: you want that behaviour to appear in test data, not in production.All of these changes display in the preview pane in real time, so you can see the effect on sample rows before generating anything.
- Pick an output mode.Click the button that opens the Data Population Wizard, then choose on the Output page: open the script in the internal editor, save it to a file at a path you specify, or execute it against the database without reviewing it.
Save to file, or open in the editor, until the project has run cleanly at least once. The third option spends the script before you have read it, and the script is where truncate, constraint disabling, and ordering all become visible.
A saved script should appear at the path you chose, ready to open in the editor or hand to
psql. - Decide the population options.The Options page carries the behavioural switches: execute the script as a single transaction (everything rolls back if any error occurs), disable CHECK constraints, disable DML triggers, disable foreign keys, disable primary keys, indexes and unique constraints, disable rules, exclude comments, and insert multiple rows per INSERT statement. Each disabled object is restored afterwards.
Single transaction is the one to leave on while you are learning the tool. The disable options exist to get data past constraints that would otherwise reject it, and using them on a database anyone else shares is how a bad load becomes everyone’s problem.
Because restoration happens as part of the run, a run that aborts partway deserves a manual check that constraints and indexes came back enabled and valid.
- Add pre- and post-population scripts if you need them.On the Additional Scripts page, supply SQL to run before or after population. Typical uses: dropping existing data, or temporarily disabling a trigger you own and re-enabling it afterwards.
Keep these scripts in the same repository as the
.dgenfile. They are part of the fixture’s definition, and they are the hook for the business rules a generator cannot know.The Additional Scripts page should show your scripts attached to the correct phase.
- Read the summary, then generate.The Summary page lists the action plan and surfaces errors and warnings that flag potential problems.
Read the warnings before you read the plan. They are the tool’s attempt to stop you from doing the thing you are about to do.
Click Generate. Afterwards, the row counts in the target tables should match the distribution you configured in step 3.
PostgreSQL types and the parent-before-child rule
Foreign keys enforce order at write time: a child row cannot reference a parent row that does not exist yet. That single rule explains most generation failures. Any tool that claims foreign-key awareness is really claiming it can order the INSERTs and carry parent key values into child rows.
When you write generation SQL by hand, you carry that ordering yourself: parents first, then children, and some way to carry parent keys into child rows when the graph is more complicated than a chain. Inside the Data Generator, the Related tables panel from step 7 is where you make the tool carry it for you.
| Type | What PostgreSQL enforces | How to configure it | Trap |
|---|---|---|---|
| integer / bigint | Fixed ranges; a value outside the range raises an error. | Use the numeric generator with a range that stays inside the column’s type. | Generating a key and letting an identity sequence supply one too; expect gaps from sequence-backed columns. |
| numeric | Exact decimal storage; values round to the declared scale. | Match precision and scale to the column. Use numeric for money, not floating point. | The money type’s output depends on the locale setting, so it travels badly between databases. Keep fixtures in numeric. |
| text / varchar(n) | varchar(n) rejects overlength strings, with a narrow exception for trailing spaces. | Constrain generated string length below your column limit if the column enforces one. | Treating text and varchar as a performance choice: PostgreSQL documents no performance difference between them. |
| boolean | True, false, and a third state: NULL. Output is always t or f. | Use a true/false value generator where your build provides one; set an explicit NULL percentage when the column allows nulls. | Assuming two states. Queries using NOT active skip NULL rows entirely. |
| date / timestamptz | timestamptz stores UTC and converts to the session time zone on display; date carries no zone at all. | Generate a date range with a seeded generator where your build supports the type, so runs stay comparable. | Generating in local time and comparing across sessions with different TimeZone settings. |
| uuid | A fixed-size identifier with lower-case hyphenated output; PostgreSQL generates v4 and v7 natively. | Let the generator produce one value per row, or default the column. | Reusing one generated UUID as the foreign key for every child row, which silently flattens your test. |
| jsonb | Decomposed binary storage that supports indexing; json keeps the exact input text instead. | Generate JSON-shaped strings where your build supports json/jsonb, and check the column accepts them. | Choosing json when you need indexing, or storing unvalidated text without checking structure. |
| bytea | Binary strings with hex and escape input formats; hex is the default output and the preferred form. | Use hex-form literals rather than hand-escaped octal strings when you supply bytea values. | Copying escape-format literals between tools and losing the backslash handling on the way. |
| enum | A static ordered set defined with CREATE TYPE; labels are case-sensitive and whitespace-significant, and separate enum types cannot be compared. | Where the generator supports your labels, generate from them; otherwise map integer ranges onto them in a post-generation script. | A generator producing a label that is not in your type: a capitalisation difference is enough to fail the insert. |

The ordering rule also explains why a partial run can look fine. Generate children without parents and the run fails loudly; generate parents without children and you get orphan-free but empty joins, which no constraint will complain about. Select both, every time, and let the Related tables panel confirm it.
Prove the load worked
Generation finishing without an error is a weak signal. A short checklist turns it into evidence.
Verify the result
- Row counts match what you configured:
SELECT count(*) FROM ordersreturns the count implied by the distribution you chose, not a number that happens to look plausible. - No orphans: a left join from child to parent, filtered where the parent key is NULL, returns zero rows.
- NULL ratios landed where you set them, checked on the specific columns you configured rather than across the whole table.
- A seed re-run into an empty scratch database reproduces the same values in the columns you set to seed mode.
- Constraints, indexes and triggers are enabled and valid again after the run, not left disabled by an aborted step.
- EXPLAIN on a representative query at the new volume shows the access path you expected, with row estimates in the right order of magnitude.
When generation fails, and how to undo it
Generation fails on a foreign-key reference
A column in a selected table references a table you left out of the run. Select the failing table, open Table generation settings, go to Related tables, and include the parent table. Regenerate and confirm the child rows now carry parent keys that exist.
Every row has the same value in one column
The column’s generator or value list is probably too narrow. Open the column settings, switch to a distribution that produces variety, and watch the preview pane before generating. If the preview looks flat, the output will be flat.
The script ran but the table is half loaded
With single transaction switched off, a mid-script error leaves the earlier statements committed. Read the error, fix the cause, then re-run with single transaction enabled so a partial failure rolls back cleanly. Reload from your backup if the half-loaded state is confusing the diagnosis.
Constraints or indexes are missing afterwards
The disable options drop objects and restore them as part of the run. If a run aborted partway, restoration may not have completed. Check the constraint and index catalogues for disabled or invalid entries, and restore anything missing from a schema script you control rather than re-running the whole generation.
You truncated the wrong table
TRUNCATE is transaction-safe with respect to data: if the surrounding transaction does not commit, the truncation rolls back. If it committed, restore from the backup you took before starting. This is exactly why the truncate checkbox deserves a second look, and why CASCADE on a referencing set of tables is worth avoiding.
dbForge, generate_series(), or Faker: pick by constraint
The three approaches solve different problems, and the differences are structural rather than a matter of taste. PostgreSQL’s generate_series() produces numbers and timestamps with interval steps; it returns zero rows if start is past stop for a positive step, zero rows if any input is NULL, and errors on a zero step. It knows nothing about your parent-child ordering. Faker is an application-level library that produces plausible field values inside your app’s language and test harness. dbForge sits between them: schema-aware, GUI-configured, and able to emit a script you can read.
| Approach | Setup speed | Foreign-key handling | Repeatability | CLI / CI automation | Licensing and cost |
|---|---|---|---|---|---|
| dbForge Data Generator | Steep learning curve; one wizard pass per project, then reopen the file. | Built in. The Related tables panel keeps parents and children consistent and fails loudly when you exclude a parent. | Seed-based value distribution plus a committed .dgen project file. | Generates command-line scripts; Studio adds CLI-powered data generation for scheduled runs. | Commercial license; confirm current trial and pricing terms with the vendor. |
| generate_series() | Fast for narrow shapes. One SQL file, no installation. | None. You order the INSERTs and supply parent keys yourself. | Strong. The file is the fixture; deterministic expressions rerun identically. | Native. psql -f executes the file in any pipeline. | Free, part of PostgreSQL. |
| Custom Faker scripts | Depends on an existing app environment and seed harness. | You own the object graph; the library helps only where you model relationships. | Depends on the seed you set in code and how much randomness you leave in. | Runs wherever your application’s test suite runs. | Free, typically open-source libraries. |
Three decision rules cover most schemas.
- Foreign keys chain across three or more tables, and a teammate who does not write SQL needs to rebuild the dataset. Use dbForge. The Related tables panel and the saved project are worth more than the license cost in that situation.
- The fixture is narrow, the schema changes often, and CI already runs psql. Write the seed with
generate_series(). The script lives in the pull request, gets reviewed with the migration, and runs unchanged in the pipeline. - Valid rows depend on application logic: totals, state transitions, derived flags. Use a Faker harness in your app’s language, because that is where the rules already live.
One more consideration tips the scale for teams on the fence: schema churn. A generator project adapts when you add a column to an existing table, because you reopen the file and tick the new column. A hand-written SQL seed needs editing in the same commit as the migration, which is either a discipline you want or a maintenance bill you keep paying.
Run the script before you run the generation
Start by configuring a project against a scratch database and choosing the save-to-file output, then read the script before it touches anything you care about. Once the file looks right, the .dgen project and the script together become a fixture your team can rebuild on demand, and the truncate checkbox stops being a gamble.
💬 Comments