Short answer
Treat each daily WHOIS CSV as an untrusted batch. Load it into a staging table with every column as text, validate and cast it, then merge into a typed table keyed on the domain name. Postgres suits an always-on store, DuckDB suits local analysis, and BigQuery suits very large history partitioned by date.
Key takeaways
- Land the raw file first, with all columns as text, and cast in a second step. One bad date should not fail a whole day of data.
- Pick a natural key (the domain name) and make the merge idempotent, so re-running yesterday's load is safe.
- Postgres is the default for a live application, DuckDB is the fastest way to explore a few weeks of files, and BigQuery fits history that runs to billions of rows.
- Empty registrant fields are normal output for redacted records. Store a flag instead of dropping or guessing the row.
- Partition or cluster by creation date from day one; retrofitting it onto a large table is far more work than starting with it.
Getting a daily WHOIS file onto your disk is the easy part. The work starts when you want to join it with last week's files, search it by registrar, or feed it to a scoring model without anyone waiting an hour for a query. A flat CSV is a delivery format, not a database.
This guide shows how to load daily WHOIS CSV files into three common stores: PostgreSQL, DuckDB and Google BigQuery. It covers the schema, a staging pattern that survives bad rows, deduplication, partitioning, and a small daily job. The column names below come from the format described on our samples page; always check the header row of your own files before you copy any SQL.
What the files look like
Our daily files are comma-separated values, zipped per day, with one archive per TLD plus a merged all-in-one file. The sample format lists columns such as domainName, createdDate, registrarName, the registrant_* contact fields, registrant_country and nameServers. Dates are plain YYYY-MM-DD strings and the nameservers are pipe-separated inside one field.
Two details shape the whole design. First, registrant fields are empty when the record is redacted or masked, so empty is data, not an error. Second, the nameserver list is a multi-value field packed into one column, which you will usually want to split later. For background on why so many contact fields are blank, see our explainer on WHOIS privacy and proxy removal.
Choosing between Postgres, DuckDB and BigQuery
| Store | Best for | Watch out for |
|---|---|---|
| PostgreSQL | An always-on store behind an app, API or dashboard; frequent small lookups by domain | You run and tune it yourself; large scans over years of data get slow without partitions |
| DuckDB | Local analysis of weeks or months of files on a laptop or one server; no server to run | Single-writer by design, so it is not a shared multi-user service |
| BigQuery | Very large history, many analysts, SQL over billions of rows | Per-query scan costs reward partitioning and clustering; plan the table layout first |
These are not exclusive. A common pattern is DuckDB for quick exploration of a fresh sample, Postgres for the live working set, and BigQuery for the long archive. Whichever you choose, the staging pattern is the same.
The staging pattern that survives bad rows
Do not load a vendor CSV straight into a typed table. One malformed date, one stray quote in an organisation name, and the whole batch fails after twenty minutes. Use two steps instead.
- 1Create a staging table where every column is text, and load the raw file into it untouched.
- 2Run validation queries on staging: row count against the file, null counts per column, dates that do not parse, domain names that are not lower-case.
- 3Cast and merge the clean rows into the typed table inside one transaction (or one job).
- 4Keep rejected rows in a side table with the file name and load date, so you can see patterns instead of guessing.
- 5Record the load in an audit table: file name, row count, load time and status.
Why text first
Loading as text moves the failure from the loader, where it is opaque, to a query you control, where you can see exactly which rows are wrong and decide what to do with them.
Loading into PostgreSQL
PostgreSQL's COPY command is the fast path for bulk loads. From psql, the client-side variant \copy reads a file from your own machine, which avoids needing server file access. A minimal setup looks like this.
Staging and target tables
CREATE TABLE whois_stage (domainname text, createddate text, registrarname text, registrant_name text, registrant_organization text, registrant_email text, registrant_telephone text, registrant_city text, registrant_country text, nameservers text); CREATE TABLE whois_domains (domain_name text PRIMARY KEY, created_date date NOT NULL, registrar_name text, registrant_name text, registrant_organization text, registrant_email text, registrant_country char(2), nameservers text[], loaded_at timestamptz DEFAULT now());
Load and merge
\copy whois_stage FROM 'new_domains.csv' WITH (FORMAT csv, HEADER true) -- then: INSERT INTO whois_domains (domain_name, created_date, registrar_name, registrant_name, registrant_organization, registrant_email, registrant_country, nameservers) SELECT lower(domainname), createddate::date, registrarname, NULLIF(registrant_name,''), NULLIF(registrant_organization,''), NULLIF(registrant_email,''), NULLIF(registrant_country,''), string_to_array(nameservers,'|') FROM whois_stage WHERE createddate ~ '^\d{4}-\d{2}-\d{2}$' ON CONFLICT (domain_name) DO UPDATE SET registrar_name = EXCLUDED.registrar_name, nameservers = EXCLUDED.nameservers, loaded_at = now();
The ON CONFLICT clause of INSERT is what makes the job idempotent. Run the same file twice and you get the same table, not duplicates. Truncate the staging table at the start of every run.
For indexing, the primary key on domain_name covers exact lookups. Add a btree index on created_date for date-range queries, and an index on registrar_name if you report by registrar. If the table will grow past a few hundred million rows, use declarative partitioning by created_date so old months can be detached or archived without a long delete.
Loading into DuckDB
DuckDB reads CSV files directly, so you can query a file before you decide to load it. Its CSV reader detects the delimiter and header, and options such as all_varchar (read every column as text), union_by_name (combine files whose columns appear in a different order) and filename (add the source file as a column) match the staging pattern above.
Query a folder of daily files
SELECT registrarname, count(*) AS n FROM read_csv('daily/*.csv', header = true, all_varchar = true, union_by_name = true, filename = true) WHERE createddate >= '2026-11-01' GROUP BY 1 ORDER BY n DESC LIMIT 20;
DuckDB reads plain CSV, so unzip the daily archives first. Once you are happy with the shape, write the data to Parquet: it stores columns compressed, keeps types, and makes later scans many times faster than re-reading CSV. A command such as COPY (SELECT ...) TO 'domains.parquet' (FORMAT parquet) is enough, and you can write one Parquet file per day to keep the folder append-only.
That append-only folder is a good fit for backtests and model training, where you want to read a date range and never edit history. If you are building a risk score from registration signals, our post on newly registered domains in threat intelligence shows what to do with the data once it is queryable.
Loading into BigQuery
BigQuery loads from Cloud Storage, so the flow is: unzip, copy the CSV to a bucket, and run a load job. Google's guide to loading CSV data from Cloud Storage lists the options. The ones that matter here are skipping the header row, supplying an explicit schema, and allowing a small number of bad records.
A load job with the bq tool
bq load --source_format=CSV --skip_leading_rows=1 --max_bad_records=100 --time_partitioning_field=createdDate --clustering_fields=registrarName,registrant_country mydataset.whois_raw gs://my-bucket/whois/2026-12-04/*.csv ./schema.json
Declare createdDate as a DATE in the schema file and the YYYY-MM-DD strings load as dates. Partitioning on that column means a query for the last seven days reads seven partitions instead of the whole table, and clustering by registrar and country prunes further inside each partition. Because BigQuery has no enforced primary key, deduplicate in SQL: load into a raw table, then write the latest row per domain name into a clean table, with a query using ROW_NUMBER() over a partition by the lower-cased domain name.
Data quality checks worth automating
A daily feed is only useful if you notice when a day looks wrong. These checks are cheap to run on the staging table and catch most problems before they reach analysts.
- Row count within a normal band for that weekday. Registrations dip on weekends, so compare like with like.
- Share of rows with a non-empty registrant_email. A sudden drop usually means a policy or source change, not a bug in your loader.
- Dates in the future, or older than the file's day by a wide margin.
- Domain names with upper-case letters, spaces or no dot.
- Duplicate domain names inside a single file.
- TLD distribution against the previous seven days.
Store the numbers, not just a pass or fail. A table of daily counts per TLD is also a useful product in its own right for registrar and market analysis.
Putting it on a schedule
The daily job is short. Fetch the new archive over FTP or the web portal, verify it is not empty, unzip it, load to staging, run the checks, merge, write the audit row, and alert on any failure. Run it from cron, a workflow runner or a small container; nothing here needs a heavy orchestrator.
Two habits save the most pain. Keep the raw downloaded files for at least a few weeks, so you can reload after a schema mistake. And make every step safe to repeat, so a failed run is fixed by running it again.
File loads or an API
Loading files makes sense when you want every new registration, history you control, and fast joins against your own tables. If you only need to enrich a list of known domains, a per-query API is simpler; our cost comparison of the API and daily downloads walks through where the break-even sits.
For reference, the Full Whois Database is $149.99 a month for daily files covering all TLDs and gTLDs, the country-filtered plan is $199.99 a month, and the WHOIS API is $2 per 1,000 queries; check the pricing page for current terms. If you want to test your loader first, the sample files are free to download, and you can ask for a specific cut at contact@getwhoisdata.com.
Frequently asked questions
Should I load daily WHOIS files into Postgres or BigQuery?+
Use Postgres when an application needs fast lookups by domain and the data fits comfortably on your servers. Use BigQuery when you keep years of history, many people run analytical queries, and you are happy to design partitions and clustering up front. Many teams use both.
Why load every column as text first?+
Because a vendor CSV will eventually contain a malformed value. Loading as text means the load itself cannot fail on a bad date, and you can find and handle the bad rows with SQL instead of debugging a half-finished import.
What should the primary key be?+
The lower-cased domain name works for a current-state table. If you want to keep every change over time, use the domain name plus the file date as a composite key and store each day's row.
How do I handle the pipe-separated nameservers column?+
In Postgres, split it into a text array with string_to_array. In DuckDB, use string_split. In BigQuery, use SPLIT. Keep the original string too if you ever need to compare against the source file.
Are empty registrant fields a data quality problem?+
Usually not. Redacted or masked records legitimately have no registrant name or email. Store the empty value as NULL, track the share of non-empty emails per day, and treat a sudden change in that share as the signal worth investigating.