Pilotbase
Articles

Everything your data stack needs.
Nothing you don't.

Data prep

Shopify bulk JSONL into SQL: __parentId joins 3 orders to 6 line items, but not 2 refunds

Shopify flattens nested connections into JSONL child lines. On a nine-line sample, __parentId rebuilt six line-item links, while two refund headers had to be read from the parent order rows. Here is a streaming loader, three-table schema and four reconciliation checks.

Data prep

We split 10,000 amounts by percentage: standard rounding failed to match the total in 6,282 of them

We tested equal and weighted allocations across 3 to 20 recipients. Rounding every row missed the original total 62.82% of the time and drifted by up to 10 cents. Largest remainder conserved every penny in all 10,000 trials.

SQL

The ECB rate file in SQL: 7,141 days, 3,042 dates to fill, and a 3,335-day ISK hole

A date-equality join loses 29.87% of one-payment-per-day rows because the ECB publishes on working days. Here are daily-table and as-of joins for PostgreSQL, MySQL 8 and SQLite, with a limit that refuses the long ISK suspension.

Data prep

Wrong-looking numbers in a CSV before you sum them: outliers, sign flips and unit mix-ups on a 50,000-row file

We checked six number columns in one public 50,000-row payroll file. A salary column held 521 hourly and daily rates (min 15.15), the z-score missed all of them, and an IQR fence found every one. 1,628 rows carry a negative; here is which to trust.

Data prep

QuickBooks Online and Xero bank CSV imports: the 3-column and 4-column layouts and the rows they reject

Bank statement CSVs imported into QuickBooks Online and Xero fail on basic structural mismatches: thousands separators, standalone zeros in debit columns, weekday names inside date strings, and leading metadata rows. Here are the exact 3-column and 4-column layouts each platform accepts, the sign rules that prevent inverted balances, a worked 42-transaction statement converted with pdfTables batch export, and eight documented rejection cases with vendor error messages.

Data prep

Nested JSON to CSV: one row per order or one row per item, worked on a Shopify-shaped order export

We flattened a 500-order, 1,074-item Shopify-shaped export two ways. One row per order keeps the totals right; one row per item turns a 46,182.20 sum into 126,859.91, and a second list (refunds) makes it worse. The SQL for PostgreSQL, MySQL and SQLite that rebuilds the totals from the items.

Data prep

Reading a CSV export before you import it: five column checks on a 50,000-row file

We ran five checks on one public file of 50,000 rows: types, empty rates, keys, dates and stray delimiters. wc -l said 135,083 lines for 50,000 rows, 33 pairs of rows repeated everything but the key, and one column was 91% placeholder.

MySQL

MySQL 8.4 doublewrite buffer ON, DETECT_ONLY or OFF: disk writes and speed measured

We ran sysbench write-only on MySQL 8.4 with innodb_doublewrite ON, DETECT_ONLY and OFF. ON wrote 27.5 KB to disk per transaction, OFF 13.5 KB and DETECT_ONLY 14.6 KB. Speed moved less than the noise of a shared cloud disk. When OFF is safe, what it means for SSD wear, and the runtime switch rules.

Data prep

We read 200,000 64-bit IDs from JSON: JSON.parse changed 99.5% of them, Python and DuckDB changed none

We wrote 200,000 snowflake-style and random 64-bit IDs to JSON and read them with six tools. JSON.parse changed 199,051 of them, by up to 512. Python, DuckDB and jq's pass-through changed none; jq with + 0 changed them like JavaScript.

MySQL

MySQL ON DELETE CASCADE: the 15-level limit, the locks it takes and a 3-level delete measured

Foreign key cascading deletes in MySQL InnoDB seem convenient until a purge triggers Error 1451, locks tens of thousands of rows across child tables, or spills megabytes of binary log events to temporary disk files. We tested InnoDB's hardcoded 15-level cascade depth ceiling, inspected secondary index gap locks in performance_schema, and measured a 3-level hierarchy (26,276 rows) on a managed MySQL 8.4 database: a single parent DELETE held exclusive locks for 482.4 ms and spilled 6.8 MB to disk, while a children-first batched purge cut lock hold times to 14.8 ms.

PostgreSQL

Partitioned tables and foreign keys in Postgres: inherited constraints, DELETE triggers and Pagila's 49 missing keys, measured

Postgres 11+ supports foreign keys on partitioned tables, but what happens across real partitions? We measured a 1.2M-row monthly schema on PostgreSQL 18.7 and inspected Pagila master: 49 of 55 payment partitions carry no foreign key, accepting orphan rows until fixed with one 59.5 ms ALTER TABLE. Includes DELETE cascade benchmarks (714 ms down to 6.2 ms with partition indexes), ATTACH costs across five validation setups (289.9 ms vs 21.4 ms), DETACH constraint behavior, and explainViewer trigger analysis.

MySQL

One big MySQL transaction stops every commit: the binlog cache, measured

A single 1 GB DELETE or bulk UPDATE does not just lock modified rows in InnoDB—it can freeze every concurrent transaction across your MySQL instance at COMMIT. Here is how binary log group commit serializes flushes, how binlog_cache_size disk spills turn milliseconds into a 13.4-second instance stall, what our benchmarks show across batch sizes and ZSTD compression, and how to safely batch large writes.

SQL

Which tables hold your user? Foreign keys, ON DELETE rules and name matches, counted on four real schemas

Before an erasure request you need the list of tables that hold the person. Read off the CREATE TABLE statements of Sakila, Pagila, Chinook and WordPress: foreign keys with their ON DELETE rule, 49 partitions with no constraint, a schema with none at all, and the delete script and leftover counts that follow.

SQL

Price lists by currency: charm endings, cash rounding and a 2% reprice band, measured

A 50,000-item catalogue priced in eight currencies against 255 real 2025 ECB fixings: daily conversion changed 5.7% to 28.1% of charm prices per business day, while a 2% exchange-rate band cut 2,032 repricing events to 44 and changed 1.32 million prices instead of 15.45 million. Includes one exact-decimal SQL pattern for PostgreSQL and MariaDB, cash steps, cheap-item traps and worked prices.

SQL

Everything you hold on one user: a subject access export to JSON from Postgres, MySQL and SQLite

When a customer submits a GDPR Article 15 subject access request or CCPA data export, you need every record linked to their identity compiled into one portable document. Pulling hundreds of child rows into an application layer to stitch JSON is slow and error-prone. Here is how to aggregate complete, multi-table customer records directly in SQL using Postgres, MySQL, and SQLite, what our lab benchmarks show for payload sizes and query times, and the critical third-party data you must leave out.

SQL

Splitting a full-name column into first and last name in SQL, and the names that break it

We ran naive first-space, last-space, and pattern parsers against a 50,000-name test dataset modeled on real customer exports. Naive space-splitting corrupted between 19.3% and 26.1% of records—breaking titles, suffixes, compound surnames, and mononyms. Here is the measured failure breakdown, exact syntax for PostgreSQL, MySQL, and SQLite, and the non-destructive architecture that prevents permanent data loss.

Guide

An audit trail with triggers: who changed which row, and what it costs per write

Build a universal SQL audit trail using database triggers in PostgreSQL, MySQL 8.4, and SQLite. Track the real application user with transaction-local session variables, store only changed columns as JSON diffs, calculate disk growth per 1,000,000 updates, and reconstruct past row states with a point-in-time SQL query.

Guide

Customer address history in SQL: valid-from rows and the as-of join

Keep each address version instead of overwriting it, close one half-open validity range when the next begins, reject overlaps, and join an order to the address that was valid when it was placed. PostgreSQL 18, MySQL 8.4 and SQLite versions, measured on 3,000,000 address versions.

Guide

A SQL retention purge you can prove ran: pg_cron, MySQL Events and an outside scheduler

We deleted 100,000 expired rows in measured batches on PostgreSQL 18.6 and MySQL 8.4.13, then tested failures, overlap, missed schedules and partition rotation. Here is a 90-day purge with a durable run log, a skipped-run alert and three ways to schedule it.

Guide

E-mail addresses before you dedupe: case, plus tags and Gmail dots in SQL

On a made-up 20-row list, provider-aware rules found six duplicate rows without a false merge. The usual lowercase-and-strip-everything recipe appeared to find ten, but four pairs belonged to different people. Here is a conservative key and unique index for PostgreSQL, MySQL and SQLite.

Guide

Restoring one table from a backup without rolling back the whole database: what a managed PostgreSQL and MariaDB login can do

A bad DELETE took 25,054 orders and 33,287 items. On managed PostgreSQL 18 and MariaDB 11.8, with no superuser and no server files, we brought back 24,919 orders and kept everyone else's newer changes. pg_restore -t leaves the primary key behind, INSERT IGNORE left every order with no items, and a restored MariaDB table left 865 orphan rows with no error.

Guide

What dpi does a scanned bank statement need for OCR? Over 15,120 amounts, 100 dpi got as few as 2% right, 300 dpi at least 95%

We ran 180 test scans of made-up statements through OCR. At 100 dpi between 2% and 80% of amounts came out right; at 300 dpi at least 95%. Low-resolution photos mostly lost the table rather than the digits, and 10 of 192 misreads had nothing on the page pointing at them.

Guide

CSV, JSON lines or Parquet for a big export: one month of taxi trips, measured

The same 4,305,006 taxi trips: 2,084 MB as JSON lines, 476 MB as CSV, 69 MB as Parquet. Parquet read 4 to 15 times faster with about 40% less memory, and it was the only one that kept a zip code as 02134. It also starts out bigger on small files, and our first streaming conversion quietly produced a valid file missing 28% of the rows.

Guide

MySQL point-in-time recovery with the binlog: stop before a bad DELETE, skip it, or rebuild the rows

A bad DELETE removed 3,925,297 rows on MySQL 8.4 while orders kept coming. We found its GTID and position with mysqlbinlog, replayed to just before it in 2.2 s, skipped it and kept the 3,800 later orders in 7.6 s, and rebuilt the rows from the binlog alone in under two minutes, with an exact checksum and 5,234,068 cascaded child rows missing.

SQL

Several currencies in one table: amounts with 0, 2 and 3 decimals and exchange rates by date

Yen with no decimals, dollars with two and Bahraini dinars with three in one payments table, converted with the ECB's real rates: an equality join on the date lost 30.2% of 600,165 payments, MySQL's LATERAL took about ten minutes where a daily rate table took under a second, POWER() put 54 payments a cent off, and rounding twice moved 41.7% of USD-to-JPY conversions by a yen. Queries for PostgreSQL, MySQL and SQLite.

SQL

SQLite ALTER TABLE: what it changes in place, and the 12-step rebuild for the rest

ADD, RENAME and DROP COLUMN on SQLite 3.54 with every refusal and its error, a trigger DROP COLUMN leaves dangling, the 12-step rebuild timed on 1,000,000 rows (2.1 s, and the view that makes step 7 fail), and two wrong rebuilds: a pragma inside the transaction that cascaded away 1,000,000 child rows, and a rename-first shortcut that points every foreign key at a dropped table.

SQL

Erasing a user for real: purging soft-deleted accounts and their rows across child tables

2,000 soft-deleted accounts erased from 5.1 million rows on PostgreSQL 18, MySQL 8.4 and SQLite: a catalog query that found eleven columns holding the user (five without a foreign key), children first in batches, orders kept for tax with the person removed, a check that every count is 0, the 621 audit rows a column search can't see, and the missing index that locked 2 million rows on MySQL.

SQL

Merging duplicate customers without breaking orders: repoint foreign keys, keep history, then delete

5,000 duplicate customers merged over 1 million orders in about a second on PostgreSQL 18 and MySQL 8.4: referencing tables found from the catalog, rules for colliding tags, cards and default addresses, an audit row per change and an undo that restored every table byte for byte. Plus the lock that held orders up for a full second, and the one that didn't.

Performance

A daily database health table: sizes, sequence use and dead rows recorded by one scheduled query

One snapshot table filled daily by pg_cron or the MySQL event scheduler, then growth, key runway and alerts in plain SQL. Over a measured week the int key's runway fell from 153 to 98 days, PostgreSQL's n_live_tup read 29% low after a vacuum, MySQL's default 24-hour stats cache froze every snapshot at day one, and InnoDB burned 9.2% more ids than rows.

Data prep

Addresses and phone numbers that match: normalising them in SQL before you compare

+44 20 7946 0123, (020) 79460123 and 2079460123 are one customer. On a made-up 100,000-row list with 12,834 known pairs, exact matches went from 17% to 100% for phones and from 6% to 100% for addresses, one rule at a time. E.164 by hand in PostgreSQL, MySQL and SQLite (no regex), a 47x MySQL speed trap, and libphonenumber compared.

Guide

A delayed replica as an undo button: recovery_min_apply_delay in Postgres, SOURCE_DELAY in MySQL, and what they cost

We deleted a million orders under load with a standby 5 minutes behind. Pausing it took 0.04 s; replaying it to the transaction before the DELETE and copying every row back took 23.9 s after we noticed, against 92.9 s for a PITR from a backup only 8 minutes old. The same on MySQL with SOURCE_DELAY and UNTIL SQL_BEFORE_GTIDS, plus the costs: WAL held on the standby, vacuum held by hot_standby_feedback, and a restart that kept 1.5 GB of WAL on the primary.

Guide

Incremental backups built into Postgres 18: pg_basebackup --incremental and pg_combinebackup, measured

We took a full backup and four incrementals of a 3 GB PostgreSQL 18 database under load. Two minutes of updates spread at random made a 765 MB incremental, a quarter of the full; the same number aimed at hot rows made 44 MB. pg_combinebackup rebuilt the data directory in 21.8 s and every row matched. Turning it on, the rule of thumb for size, three ways to break the chain, and pgBackRest file-level vs block incremental next to it.

SQL

Soft deletes in SQL: deleted_at, unique keys that still work, and the queries that forget the filter

deleted_at vs an is_deleted flag vs an archive table on PostgreSQL, MySQL and SQLite: partial unique indexes so a deleted user can sign up again (and the flag that fails on the second delete), MySQL's generated-column workaround, index sizes and a count with 30% of a million rows deleted (39 MB vs 27 MB, 16.3 ms vs 6.2 ms), views and row-level security for the forgotten filter (and the RLS policy that refuses the soft delete itself), and foreign keys that still point at deleted rows.

SQL

JSON columns in Postgres vs MySQL: jsonb, indexes and the queries that differ

The same 500,000 products in PostgreSQL 18 and MySQL 26.7: what each engine stores, the JSON null that MySQL turns into a string, prices that compare as text, an index MySQL silently ignores, GIN against multi-valued indexes, and what a SQL translator gets wrong with JSON.

Performance

Table bloat in Postgres: measure it with pgstattuple, then VACUUM FULL or pg_repack

We deleted half the rows of a 2 GB table on PostgreSQL 18. Plain VACUUM gave back 0 MB, and pgstattuple found 48.5% of the file free. VACUUM FULL got it to 1,009 MB in 35.6 s and made a one-row SELECT wait all 35.6 s. pg_repack did the same in 36.2 s with a worst wait of 0.37 s. Both needed 1.4 GB of extra disk, and REINDEX CONCURRENTLY halved the indexes without blocking anything.

Guide

Point-in-time recovery in Postgres: restore to the second before the bad DELETE

A typo in a purge deleted 5,909,287 rows on PostgreSQL 18. With a pgBackRest backup and the WAL archive we found the DELETE's exact commit with pg_waldump and restored to just before it: 28 s of files and 20 s of replay for a 7.1 GB database, on a new timeline. What the rewind cost (4,309 newer orders), the recovery_target_inclusive trap, restoring beside production instead, and what an S3-compatible repository costs per month.

Migration

Running out of int: finding id columns near 2,147,483,647 and moving them to bigint

The queries that list every int key and sequence with the share of its range used on PostgreSQL and MySQL (including the day-old number MySQL shows by default), the exact errors at the limit, why upserts burn ids, and int to bigint on 10 million rows timed both ways: a 55-second exclusive lock for the one-line ALTER against an 18 ms swap after a background backfill, plus MySQL's 4-minute copy and the foreign keys that must change with it.

Performance

Postgres EXPLAIN ANALYZE, read top-down: the five nodes that matter

How to read a PostgreSQL query plan in two minutes: start at the top, follow the time down to the node that owns it, multiply by loops, and compare estimated with actual rows. Then the five node types behind most slow queries, with real plans from a 2-million-row table.

SQL

Pivot tables in SQL: crosstab, FILTER and CASE

Turning rows into columns in Postgres, MySQL, DuckDB and SQL Server: FILTER and CASE, NULL versus 0 for empty cells, the crosstab form that silently shifts values into the wrong month, columns you don't know in advance, and unpivoting a spreadsheet back into rows.

Data prep

Near-duplicate customers in a list: pg_trgm, a clean-up first, and precision measured on 50,000 rows

Jon Smith, JOHN SMITH, Smith, John and J. Smith: we hid 4,720 duplicate pairs in a made-up 50,000-customer list and measured pg_trgm at every threshold. At 0.5 it finds 95% of them inside 180,000 pairs; identical names are the same customer only 35% of the time. What a second column, levenshtein, a GIN index (and a 28x slower GiST plan) change, plus SOUNDEX and a portable trigram query for MySQL and SQLite.

SQL

Money in SQL: numeric vs float vs integer cents, and the rounding you can measure

One million rows of 0.10 summed as float, double, numeric, integer cents and money on PostgreSQL, MySQL and SQLite (PostgreSQL's real sum changed on every run, from 99,795 to 100,958), ROUND's three different rules side by side, tax per line vs on the total (39% of 100,000 invoices differ by a cent or two), a split that adds up in all three engines, and the SQLite cast that drops a cent on 65,624 of a million amounts.

Data tools

Comparing two CSV exports to find what changed

Two nightly exports of the same product list: which rows were added, removed or changed? Why diff gets it wrong, how to compare by key in the browser with csvDiff, how to tell real changes from formatting noise, and the FULL JOIN that does it in Postgres.

Performance

Deleting millions of rows without hurting production: batched DELETE, partitions and DROP

We purged 2,960,527 of 10 million rows on PostgreSQL 18 and MySQL 8.4 while an app kept writing. One DELETE: 21 s on Postgres with updates stuck for 20 s, 110 s on MySQL with seven lock-wait timeouts. Batches of 10k: three times longer, worst wait 0.17 s, plus the dead rows autovacuum leaves behind. Dropping monthly partitions: 0.3 s and 600 MB of disk back, if you avoid the lock queue. WAL, replica lag, and how to size the pause.

SQL

A comma-separated column into rows: tags into a join table on Postgres, MySQL and SQLite

Splitting 'red,blue, green' into rows on PostgreSQL 18 (string_to_table WITH ORDINALITY), MySQL 8.4 (JSON_TABLE, recursive CTE) and SQLite (json_each): trimming, empty items, order and repeats, a tags + item_tags join table built from 1,000,000 rows (16.6 s vs 6.8 s with keys added after; 1 min 20 s vs 30 s on MySQL), why LIKE and FIND_IN_SET give the wrong count, and GROUP_CONCAT's 1,024-byte cut on the way back.

Guide

Full-text search without Elasticsearch: 1M products in Postgres, MySQL FULLTEXT and SQLite FTS5, measured

The same million product rows searched ten ways on PostgreSQL 18, MySQL 8.4 and SQLite FTS5: build time and disk, match counts and query times, ranking that needs fixing on every engine, and the rules that bite (MySQL returns 0 rows for 4k video and for the office, SQLite errors on usb-c). Plus the LIKE '%word%' baseline, what each index costs on inserts, and when a search engine is worth adding.

Guide

Summary tables that stay fresh: materialized views vs incremental rollups in Postgres and MySQL

On 10 million events a dashboard query took 1.3 s. A materialized view cut it to 19 ms, but every REFRESH re-reads the whole table: 2.0 s, 2.9 s with CONCURRENTLY, and the plain one froze readers for 1.8 s. An hourly rollup table that re-counts only the hours that got rows takes 8 to 11 ms a run and catches late rows a last-two-hours window silently drops. Measured on PostgreSQL 18 and MySQL 8.4, plus the pg_cron time-zone trap that misfiled our first scheduled runs.

Guide

Shopify, Square and ad spend in one weekly table, without a data warehouse

Once a month you export orders from Shopify, sales from Square and spend from Meta and Google, then glue them together in Excel. Here are the three places that merge goes wrong, with the numbers from a sample month, and a way to get the weekly table without uploading anything.

SQL

Running totals and moving averages in SQL: window frames, ROWS vs RANGE

A running balance, a 7-day moving average and month to date are one SUM or AVG with OVER, and the frame decides whether the number is right: the default RANGE frame gives tied rows the day-end total, 7 ROWS on data with missing days averaged four weeks of March into an April figure, and SQLite accepted a RANGE frame on a text date without an error and averaged nothing. Each case on PostgreSQL, MySQL and SQLite, plus timings on a million rows.

Performance

Foreign keys without an index: slow deletes and lock waits in Postgres and MySQL

PostgreSQL doesn't index the referencing column of a foreign key. Deleting 1,000 customers who had no orders took 20.8 s against a 1-million-row orders table, 1,000 full scans and a billion rows read, and blocked inserts and updates on those customers for the whole time; with the index it took 3.8 ms. What MySQL does instead, a catalog query that finds every unindexed foreign key, and which ones to leave alone.

Data prep

Semicolon CSVs and decimal commas: a European Excel export into a database

A CSV from Excel in Germany, France or Italy uses semicolons and writes 2.112,99. We loaded one into four databases: PostgreSQL refused every row, MySQL's LOAD DATA LOCAL loaded all 1,000 with amounts cut to 2.11 and every date set to zero, without an error even in strict mode, and SQLite summed text to 196,319 instead of 4,540,731. Why, and the fix for each.

Performance

Changing a big MySQL table: ALGORITHM=INSTANT, INPLACE, gh-ost and pt-online-schema-change

We timed eleven ALTERs on a 10-million-row MySQL 8.4 table with writes running: INSTANT ones took 0.00 s, INPLACE ones 16 to 52 s with writes slowed, and two COPYs blocked every write for 40 and 67 s. Then the 64-version limit that turned a 0 s ADD COLUMN into 65 s, an open transaction that froze an INSTANT change for 8 s, and the same COPY change done by pt-online-schema-change (210 s, 1.9 s worst stall) and gh-ost (30 min, 3.6 s), with foreign keys.

Migration

Upgrading Postgres 16 to 18 with logical replication: a 0.28-second cutover, measured against pg_upgrade and dump/restore

We upgraded the same 5.5 GB database from PostgreSQL 16 to 18 three ways while a script kept writing to it. Dump and restore: 146 s with writes stopped. pg_upgrade --link: 3.7 s, after PostgreSQL 18's new checksum default made the first attempt fail. Logical replication: a 239 s copy with the app still writing, then 0.28 s between the last write on 16 and the first on 18. Every step, plus the traps: tables without a primary key, DDL that stalls replication, and sequences that don't come along.

Performance

MySQL slow query log: find the queries worth fixing with pt-query-digest and performance_schema

With MySQL's default long_query_time of 10 seconds, the slow log caught none of the 40,604 queries in our test, while three missing indexes cost 31 of 43 seconds of server time. How to log everything for a short window, rank it with pt-query-digest, get the same ranking from performance_schema with no log file, use rows examined per row sent as the tell, and what happened when we added the indexes, including the report that got slower.

SQL

Recursive CTEs for trees: categories, org charts and bills of materials

Everything under a category, everyone who reports to someone, how many bolts go into one bike: WITH RECURSIVE walks a parent_id table on PostgreSQL, MySQL 8 and SQLite. Tested on all three: depth and path columns, tree order for display, MySQL's path that silently stops at 40 characters, what each engine does with a loop in the data, and a 200,000-node tree timed against a closure table and ltree.

SQL

A calendar table in SQL: one row per day for reports that don't skip empty days

Group a year of orders by day and you get 344 rows for 365 days: Christmas, Thanksgiving and the quiet Sundays just vanish. A calendar table puts them back with one LEFT JOIN, and its business-day number turns "10 business days after the 19th" into a lookup. Built and tested on PostgreSQL 18, MySQL 8.4 and SQLite, with the MySQL 1,000-row recursion limit, the SQLite version trap, same-weekday-last-year comparisons and timings.

Guide

Your first Postgres database: an owner, an app user that isn't the superuser, and the grants between them

Connecting your app as postgres works until it doesn't. Fifteen lines of SQL give you a database owner for migrations and an app user that can read and write rows but can't drop a table. We ran every step on PostgreSQL 18 and hit the three traps on the way: permission denied for a serial's sequence, a new table the app can't see because ALTER DEFAULT PRIVILEGES was run by the wrong role, and pg_hba.conf errors that look alike but mean different things.

SQL

NULL in SQL: the five places it gives the answer you didn't expect

NOT IN returned no rows because of one NULL, AVG divided by 3 instead of 5, and PostgreSQL put unshipped orders at the top of a DESC sort while MySQL put them at the bottom. We ran the same queries on PostgreSQL 18, MySQL 8.4 and SQLite, then loaded each engine's CSV export into the others: only 4 of 9 loads kept NULL and the empty string apart. What each engine does, and the one-line fix for each.

Data prep

Leading zeros and long numbers: what Excel does to IDs in a CSV

02139 became 2139, a 16-digit order number came back as 4.11111E+15, and MySQL stored that as 4111110000000000 without a warning. One file of ZIP codes, phone numbers, product codes and 15- to 19-digit IDs through Excel, PostgreSQL 18, MySQL 8.4, SQLite and JavaScript: what each one changes, which column type to use, and how to open and load the file so nothing is lost.

Data prep

Dates in CSV files: 03/04/2025 is two different days

The same CSV opened on a US and a UK laptop: Excel turned 03/04/2025 into two dates 30 days apart and wrote two-digit years back on save, and PostgreSQL loaded a file of wrong dates without an error. What Excel, PostgreSQL 18, MySQL 8.4 and SQLite each do with day/month order, two-digit years and Excel serial numbers, and how to fix the file once.

Guide

Row-level security in Postgres for a multi-tenant app: policies, the app role and the leaks

RLS puts WHERE tenant_id = ? into the database so no query can forget it. We tried the ways it quietly doesn't apply on PostgreSQL 18: the table owner, a SET that outlives the request in a pool, views, SECURITY DEFINER functions, foreign keys and unique constraints; plus what the policy costs per query and what MySQL offers instead.

SQL

Gaps and islands in SQL: streaks, missing days and sessions with window functions

Login streaks, days a sensor didn't report and 30-minute click sessions are one problem: runs with holes between them. The queries for PostgreSQL, MySQL 8 and SQLite, run on a million rows each, plus the two places the obvious version is quietly wrong (one cost us 71,743 extra streaks).

Performance

PgBouncer transaction pooling: what breaks and what gets faster

Through PgBouncer, a new-connection-per-request app ran 27 times faster and 500 clients needed only 20 Postgres backends. Transaction mode also leaked one client's statement_timeout into another's queries, let two workers hold the same advisory lock and dropped LISTEN notifications. Measured on PostgreSQL 18 and PgBouncer 1.26.

Guide

Your export is too big for Excel: three ways to open it

Excel shows the first 1,048,576 rows of a file and leaves the rest out. Here's what not to click next, and three ways to get the whole export into something you can work with: a smaller export, Excel's data model, or files cut to fit.

Performance

One idle-in-transaction session: how it stops VACUUM on every table

One session that wrote a row and then sat idle stopped VACUUM for the whole database: autovacuum ran three times and removed nothing, and the table grew from 70 to 102 MB in three minutes, size it kept after the session was killed. We tested twelve possible holders on PostgreSQL 18; a plain BEGIN; SELECT 1 wasn't one of them.

Performance

Autovacuum falling behind: dead tuples, per-table thresholds and the cost limit

A 5M-row table taking 3,000 updates a second: with the defaults autovacuum waited until 1.07 million dead rows, then spent 28 of its 32 seconds asleep. A per-table scale factor cut dead rows seven-fold but wrote five times the WAL, a higher cost limit made each pass 3 seconds, and no setting stopped the updated_at index from growing.

SQL

Fake data that looks real: generate_series, random() and a million test rows in SQL

A million realistic orders in plain SQL on Postgres, MySQL 8.4 and SQLite: skewed customers, weighted statuses, NULL rates and a weekly pattern. On uniform data a customer's newest orders read 12 pages; on skewed data the biggest customer read 7,886. And MySQL and SQLite quietly re-ran rand() in every WHEN, turning a 3% status into 0.1%.

Data prep

From a spreadsheet to a database: when VLOOKUP becomes a JOIN

A shop's shared workbook with a Customers sheet and an Orders sheet. VLOOKUP without its last argument put 5 of 10 orders on the wrong customer, SUMIFS lost 364 of 2,358.50 without a warning, and a renamed customer was silently read twice. The same data as two tables, the JOIN and GROUP BY that replace the formulas, and how to make the move without losing Excel.

Performance

Loading a million rows: COPY, multi-row INSERT and executemany, measured

The same 1,000,000-row CSV into PostgreSQL 18 and MySQL 8.4 eleven ways. COPY took 1.7 seconds, multi-row INSERTs about 12, psycopg2's executemany 75, and one commit per row 11 minutes on Postgres and 38 on MySQL. Indexes made COPY six times slower, a CRLF file loaded 18 rows into MySQL with one warning, and the batch size barely mattered.

SQL

Removing duplicate rows in SQL: keep the newest per key on Postgres, MySQL and SQLite

A contacts table with 1,002,000 rows and 952,000 emails, cleaned on PostgreSQL 18, MySQL 8.4 and SQLite. The window-function DELETE took 0.6 to 4.9 seconds everywhere; a self-join without an index was still running on MySQL after five minutes. Plus the tie that kept a different row in 473 cases, the 2,000 duplicates GROUP BY didn't see, and the unique index that stops it happening again.

Data prep

Mojibake in your CSV: UTF-8, the BOM and Windows-1252 between Excel and a database

José turns into José, a CSV load stops at line 2, and an id column fails on "1". We sent one customer export through every path between Excel, PostgreSQL 18, MySQL 8.4 and SQLite: what each encoding mistake looks like, which ones fail loudly and which load without a word, and how to repair them once.

Guide

A pg_dump you have never restored is not a backup: formats, parallel restore and a restore test

We dumped a 2.2 GB PostgreSQL 18 database in every format and restored each one into a fresh server: the first restore failed on 7 missing roles and grants, the database's own settings didn't come back without --create, a selective restore lost an index to a missing extension, and -j 4 only helped once there were several big tables (30 s to 17 s). With the nightly restore test script we ended up with.

SQL

timestamptz, timestamp and DATETIME: time zone bugs between Postgres and MySQL

We inserted the same instant from New York and Tokyo sessions into PostgreSQL 18 and MySQL 8.4: timestamp and DATETIME columns stored values 13 hours apart, the two engines picked different instants for the DST hour that happens twice, a daily report moved 7 of 48 orders to another day, and MySQL's TIMESTAMP refused 2038-01-19 03:14:08. With AT TIME ZONE in both directions and CSV exports.

Performance

Partial indexes: index only the rows your queries ask for

On 5M orders with 1% pending, a partial index was 1.1 MB instead of 152 MB and cut insert time by 44%, but read the same few pages as the full index. Where it really pays, the parameterised query that can't use it (171 ms vs 0.06 ms), partial unique indexes for one active row per user, and MySQL's workaround that scanned 4.95M NULLs.

SQL

Upserts in Postgres, MySQL and SQLite: ON CONFLICT, ON DUPLICATE KEY and MERGE

We ran the same upserts on PostgreSQL 18, MySQL 8.4 and SQLite. A second unique key gives an error on two engines and silently updates the wrong row on MySQL; MERGE fails with a unique violation when two sessions insert the same key, where ON CONFLICT doesn't; on a 1M-row batch MERGE was 35% faster than ON CONFLICT. Plus burned ids, RETURNING, REPLACE and translating between them.

Guide

Your bank only gives you a PDF. Here's how to get the transactions into Excel

Copy and paste from a PDF statement lands everything in one column, and the online converters want you to upload your bank statement to a stranger. Here's what works instead, what goes wrong with dates and minus signs, and a one-column check that tells you nothing was lost.

Performance

Deadlocks in Postgres: read the log entry, find both statements, fix the lock order

We reproduced three deadlocks on PostgreSQL 18 (two transfers, a batch upsert and a foreign key), read the server log line by line, caught one live with pg_blocking_pids, and measured the fixes: locking rows in id order took 2,400 contended transfers from 69 s and 1,096 deadlock retries to 5.5 s and none. With the retry code for 40P01 and MySQL's SHOW ENGINE INNODB STATUS for comparison.

Performance

pg_stat_statements: find the five queries worth tuning first

The slowest query is rarely the one to fix first. We ran a mixed workload on PostgreSQL 18, ranked pg_stat_statements by total time, mean, calls against rows, blocks read and WAL written, and fixed the top statement: 88% of the server's time, one missing index, 4.1 times the throughput. Here are the ranking queries, what each one finds, and what pg_stat_statements can't see.

Performance

HOT updates in Postgres: why one index on updated_at slows every update

An index on a column your app sets on every update switches off HOT updates. On PostgreSQL 18 it took a 1M-row table from 98% HOT to 0%, cut updates per second by a third and tripled the index size in a minute. We measured fillfactor 100, 90 and 70, BRIN instead of B-tree and a partial index, and show the query that finds the tables where it's happening.

Performance

A SELECT that wrote 485 MB of WAL: hint bits, checksums and the first read after a bulk load

On a fresh PostgreSQL 18 cluster, the first count(*) over 4 million newly loaded rows wrote 485 MB of WAL, nearly the size of the table, and the second wrote none. Hint bits plus data checksums, now on by default, explain it. We reproduce it, read it in EXPLAIN (ANALYZE, WAL), show what it does to replicas and backups, and measure VACUUM and COPY FREEZE as ways to pay it at load time.

Performance

OFFSET gets slower on every page: keyset pagination in Postgres, measured

Page 50,000 of a 5 million row table took 1.5 seconds with OFFSET and 0.04 ms with a keyset query; page 1 took the same either way. We measured both on PostgreSQL 18, then worked through what trips keyset pagination up: ties in the timestamp, NULLs, mixed sort directions, page numbers, and text keys whose order depends on the collation.

Performance

SQLite in production: WAL, busy_timeout and backups that work

Four processes writing to one SQLite file: with the defaults half the writes failed with "database is locked". WAL stopped readers from waiting, but busy_timeout changed nothing until the transactions used BEGIN IMMEDIATE, and then none failed. Plus what synchronous costs, why cp of a live database gave a corrupt copy and .backup never finished, foreign keys that are off by default, and STRICT tables, measured.

Performance

Adding NOT NULL, a foreign key or a check to a big Postgres table without a long lock

We added a foreign key, a check and NOT NULL to a 5-million-row Postgres table, read the locks from pg_locks, and ran a live workload against it. Each one-step statement held its lock for 0.2-0.3 s. Behind a 6-second report, the same 0.2 s ALTER froze every app connection for over 5 s. NOT VALID + VALIDATE, the check-constraint route to NOT NULL, and lock_timeout with retries, measured.

Performance

Case-insensitive text in Postgres: citext, lower() or a nondeterministic collation

Three ways to make an email column ignore case in Postgres, measured on a million rows. All three stop the duplicate sign-up and look a user up in a few microseconds. citext took 7.3 seconds to sort them where a case-insensitive collation took 1.0, its indexes don't deduplicate, and a parameter typed text silently turns it case-sensitive. LIKE, Unicode, and how to migrate a live column.

Guide

Invalid indexes in Postgres: where they come from and how to clear them

A CREATE INDEX CONCURRENTLY that fails doesn't clean up after itself. We left invalid indexes behind four ways on PostgreSQL 18 and found two kinds: one costs nothing but its name, the other more than doubled the time and WAL of every insert while no query could use it. The query that finds them, which fix fits which kind, and the check to run before a migration.

Performance

Virtual generated columns in Postgres 18: compute on read instead of storing

PostgreSQL 18 made VIRTUAL the default for generated columns. On 2 million rows, six virtual columns took 381 MB where the stored ones took 537 MB, and loaded in half the time. Reading a text one back was three times slower, the planner guessed 10,000 rows for 200,000, and you can't index them. When virtual wins, what it can't do, and how to convert a stored column.

Performance

uuidv7 in Postgres 18: should you switch your primary keys?

We put 10 million rows into three tables keyed by bigint, uuidv4 and uuidv7 on PostgreSQL 18. Random uuids filled index pages to 70%, wrote 15 times the WAL per insert batch and took 20 times as long. uuidv7 stayed close to bigint. What to switch, what to leave, and the one-line migration.

Performance

Unused and duplicate indexes in Postgres: find them, then drop them safely

Five of the eight indexes on our orders table were never scanned on the primary. One of them served every report on the replica. How to find unused, duplicate and prefix indexes on every node, what dropping them gained (1.6x the throughput, a sixth of the WAL), and how to drop them without blocking writes.

Comparison

A DBeaver alternative in the browser: what moves to a tab, and what doesn't

DBeaver is a desktop app, and sometimes the database is somewhere your desktop isn't. What you keep and what you lose when the client moves to a browser tab, DBeaver's own answer (CloudBeaver) next to ours (Pilotbase) in one honest table, and the cases where you should simply keep DBeaver.

Performance

When Postgres guesses wrong: row estimates, ANALYZE and CREATE STATISTICS

A join planned for 1 row got 100,000 and ran for 5 minutes 21 seconds; after ANALYZE, 181 ms. Four ways a row estimate goes wrong (a load nobody analyzed, columns that say the same thing, a function around the column, a long tail of values) and the fix for each, with real plans.

Performance

Sorting text in Postgres is slow: collations, COLLATE "C" and when work_mem doesn't help

Sorting 500,000 emails took 1.4 seconds with 4 MB of work_mem and 1.4 seconds with 256 MB. By integer: 0.13. With COLLATE "C": 0.25. What a collation costs per comparison, how to spot it in a plan, and four ways out, one of which also fixes LIKE 'abc%'.

Migration

SQLite to Postgres when the side project grows up

We moved a real-shaped SQLite database to PostgreSQL three ways and counted what broke: 72,937 errors from a piped dump, then a pgloader run that took under a second and exited clean with 28 rows missing, two foreign keys skipped and booleans stored as text. What to fix in SQLite first, what to finish in Postgres, and which queries change their answers.

Data tools

Schema diffs before a deploy: what sqlCompare catches

Dump staging and production with pg_dump, strip the noise (owners, grants, the random \restrict key), and diff the two files. On a test pair it found four changes we were shipping and six nobody had written down. And one thing no dump will show.

Comparison

Adminer, pgweb, CloudBeaver, Pilotbase: four ways to put your database in a browser tab

We started all four against the same Postgres with a 200,000-row orders table and wrote down what Docker reported: 8 MB of memory for the smallest, 345 MB for the largest, and ours is not the small one. The commands, the screenshots, who each one suits, and what each leaves open by default.

Comparison

DBeaver is using 1.8 GB doing nothing? We measured it, and our own app too

Forum threads say DBeaver eats 1-2 GB sitting idle. We installed DBeaver 26.2.2 and Pilotbase Desktop on the same Windows laptop, pointed both at the same Postgres and wrote down what Task Manager said. The answer was less dramatic, and less flattering to us, than we expected.

SQL

The AI wrote a query that looked right: five checks before you trust the number

Five ways a generated SQL query runs cleanly and still returns the wrong number (join fan-out, BETWEEN on timestamps, NOT IN with NULLs, integer division, a LEFT JOIN undone by WHERE), with real results from Postgres 16, and a short routine to catch them.

Guide

A database GUI next to the databases your server panel runs

Coolify, Dokploy, Easypanel, Openship and Doktainer make databases easy to start and hard to look inside. How to run a web database client on the panel's private network, with no published database port, a read-only user and a login in front.

Guide

Turn your database tables into a REST API with Pilotbase

Right-click a database, tick the tables your app may use, mint a token and call list, read, create, update and soft-delete routes. A tested walkthrough with real screenshots, plus where it works (Docker on a server) and where it doesn't (the desktop app).

Migration

MySQL to PostgreSQL: what a SQL translator fixes, and what you still fix by hand

We ran everyday MySQL through a SQL translator (sqlglot) and checked the output against PostgreSQL 16. Queries come across well, down to NULL ordering and division. Upserts, CREATE TABLE, UPDATE ... JOIN and case-sensitive LIKE don't. The fixes for each, and a migration order that works.

Data tools

A messy CSV into Postgres without surprises: profile, clean, then load

One messy export: doubled spaces, ZIP codes with leading zeros, day-first dates, an empty column, a duplicate row and a formatted amount. What Postgres does with each, and a three-step way to load it right with free browser tools and COPY.

Comparison

pgAdmin 4 vs Pilotbase: the same Postgres jobs, side by side

We pointed pgAdmin 4 (9.18) and Pilotbase at the same PostgreSQL database and did the same jobs in each: connect, browse, query, edit, back up, diff schemas and use AI. Screenshots of both, with an honest verdict for each task.

Security & ops

Migrate, back up, and expose your data safely

Schema and data migration between connections, on-demand backups, SQL export, encrypted credentials and an optional generated REST API: the operational tools that go with day-to-day database admin.

Vector search

Vector databases are first-class citizens

Qdrant, ChromaDB, Weaviate, Pinecone and Milvus get the same connection tree, browsing and editing tools as any SQL database, for teams running RAG pipelines alongside their usual data.

Open source

Open source under MIT, and yours to self-host

Pilotbase is MIT-licensed: free to use, modify, self-host and redistribute, including commercially. The source is on GitHub, and a Docker quick start gets it running in a few minutes.

Desktop app

Pilotbase is now a native desktop app

The same FastAPI backend and React UI in an Electron shell, with a bundled backend and local SQLite storage: no Docker, no Postgres, no ops. Installers for Windows, macOS and Linux.

AI agent

Ask your database a question — the AI agent writes the query

Pilotbase's AI agent reads your schema, turns a plain-English question into a query, runs it in your editor, and holds every write for your approval. Destructive statements are blocked outright.

Unified admin

One tool now covers 19 database engines

PostgreSQL to Pinecone, MySQL to Milvus: Pilotbase connects to relational, NoSQL and vector databases from one interface, so you stop installing a different admin tool for every database you run.