title: Postgres dump of only parts of tables for a dev snapshot
body: <p>On production our database is a few hundred gigabytes in size. For development and testing, we need to create snapshots of this database that are functionally equivalent, but which are only 10 or 20 gigs in size. </p>
  
  <p>The challenge is that the data for our business entities are scattered across many tables. We want to create some sort of filtered snapshot so that only <em>some</em> of the entities are included in the dump. That way we can get fresh snapshots every month or so for dev and testing.</p>
  
  <p>For example, let's say we have entities that have these many-to-many relationships:</p>
  
  <ul>
  <li>Company has N Divisions</li>
  <li>Division has N Employees</li>
  <li>Employee has N Attendance Records</li>
  </ul>
  
  <p>There are maybe 1000 companies, 2500 divisions, 175000 employees, and tens of millions of attendance records. We want a replicable way to pull, say, the first 100 companies <em>and all of its constituent divisions, employees, and attendance records</em>.</p>
  
  <p>We currently use pg_dump for the schema, and then run pg_dump with --disable-triggers and --data-only to get all the data out of the smaller tables. We don't want to have to write custom scripts to pull out part of the data because we have a fast development cycle and are concerned the custom scripts would be fragile and likely to be out of date.</p>
  
  <p>How can we do this? Are there third-party tools that can help pull out logical partitions from the database? What are these tools called?</p>
  
  <p>Any general advice also appreciated!</p>