Both MySQL and PostgreSQL are battle-tested, open-source relational databases that run reliably on a Hong Kong VPS. The choice between them is not about one being universally “better” — it is about which database’s strengths align with your application’s specific needs. This guide examines the meaningful differences to help you choose correctly from the start.
Quick Decision Guide
| Choose PostgreSQL if… | Choose MySQL if… |
|---|---|
| Complex queries with CTEs, window functions, lateral joins | Simple CRUD operations are 90% of your workload |
| JSON/JSONB document storage with indexing | Your framework ecosystem strongly favours MySQL (Laravel, some WordPress plugins) |
| Full-text search without Elasticsearch | Read-heavy workloads with simple SELECT patterns |
| Strong ACID compliance and data integrity are paramount | Maximum compatibility with legacy systems and tools |
| Geospatial data (PostGIS) | Galera Cluster or Group Replication for MySQL-specific HA |
| Custom data types and operators | Existing team expertise is MySQL-specific |
| Financial applications needing exact decimal arithmetic | Simpler operational tooling for your team |
Performance Characteristics
Read Performance
MySQL (InnoDB) is generally faster for simple primary-key lookups and sequential scans on tables that fit in the buffer pool. PostgreSQL’s planner is more sophisticated — it consistently makes better decisions on complex queries involving multiple joins, subqueries, and aggregations.
| Query Pattern | MySQL | PostgreSQL |
|---|---|---|
| Simple PK lookup (id = ?) | Slightly faster | Comparable |
| Multi-table JOIN (3+ tables) | Good | Better (smarter planner) |
| Aggregation on large tables | Good | Better (parallel query) |
| Full-text search | Basic (limited ranking) | Better (tsvector, ranking) |
| JSONB queries with GIN index | Not supported | Very fast |
| Window functions | Supported (MySQL 8+) | Better optimised |
Write Performance
MySQL’s InnoDB write performance is excellent for workloads with many small transactions. PostgreSQL’s MVCC (Multi-Version Concurrency Control) implementation provides better write concurrency under heavy mixed read/write loads — readers never block writers and vice versa.
<code"># Benchmark on your specific VPS with sysbench: # MySQL OLTP test sysbench oltp_read_write --db-driver=mysql \ --mysql-host=localhost --mysql-user=root \ --mysql-password=pass --mysql-db=sbtest \ --tables=4 --table-size=1000000 \ --threads=8 --time=60 run # PostgreSQL OLTP test sysbench oltp_read_write --db-driver=pgsql \ --pgsql-host=localhost --pgsql-user=postgres \ --pgsql-password=pass --pgsql-db=sbtest \ --tables=4 --table-size=1000000 \ --threads=8 --time=60 run
JSON Support: PostgreSQL’s Major Advantage
PostgreSQL’s JSONB type stores JSON as a parsed binary structure with indexing support — enabling fast queries on semi-structured data without moving to a document database.
<code">-- PostgreSQL JSONB: store and query document-style data
CREATE TABLE products (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
attributes JSONB,
created_at TIMESTAMPTZ DEFAULT NOW()
);
-- Index specific JSON paths for fast lookup
CREATE INDEX idx_products_category
ON products ((attributes->>'category'));
CREATE INDEX idx_products_tags
ON products USING GIN (attributes->'tags');
-- Query by JSON attribute (uses the index)
SELECT * FROM products
WHERE attributes->>'category' = 'electronics'
AND attributes->'price' < '1000'::jsonb; -- Search for tag in JSON array SELECT * FROM products WHERE attributes->'tags' @> '["wireless"]'::jsonb;
MySQL 8+ has JSON support, but without the GIN indexing that makes PostgreSQL JSONB queries fast on large datasets. For applications blending relational and document-style storage, PostgreSQL eliminates the need for a separate MongoDB or Elasticsearch instance.
Full-Text Search: PostgreSQL vs External Search
<code">-- PostgreSQL native full-text search
ALTER TABLE posts ADD COLUMN tsv_content tsvector
GENERATED ALWAYS AS (
setweight(to_tsvector('english', coalesce(title, '')), 'A') ||
setweight(to_tsvector('english', coalesce(body, '')), 'B')
) STORED;
CREATE INDEX idx_posts_fts ON posts USING GIN (tsv_content);
-- Fast full-text search with ranking
SELECT title, ts_rank(tsv_content, query) AS rank
FROM posts, plainto_tsquery('english', 'hong kong vps hosting') query
WHERE tsv_content @@ query
ORDER BY rank DESC
LIMIT 10;
For Chinese full-text search (Simplified or Traditional Chinese), PostgreSQL requires the zhparser or pg_jieba extension. These are more complex to install but enable Chinese language search without Elasticsearch. For most teams, Elasticsearch or OpenSearch remains the better choice for Chinese full-text search at scale.
Replication and High Availability
PostgreSQL Streaming Replication
<code"># PostgreSQL built-in streaming replication is simple and robust # On primary (postgresql.conf): wal_level = replica max_wal_senders = 3 synchronous_commit = on # On replica: # pg_basebackup copies primary data, then replica streams WAL changes pg_basebackup -h PRIMARY_IP -U replicator -D /var/lib/postgresql/16/main -P -Xs -R
MySQL Group Replication / Galera
<code"># MySQL Group Replication — multi-primary or single-primary # More complex setup but supports automatic failover without external tools # Best for teams already invested in MySQL tooling
Both databases support read replicas for scaling read-heavy workloads. PostgreSQL’s streaming replication is simpler to configure; MySQL’s Group Replication offers more topology options but requires more operational expertise.
Data Integrity and Constraints
PostgreSQL enforces constraints more strictly by default — a difference that catches data integrity issues earlier:
<code">-- PostgreSQL: full CHECK constraint support
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
status TEXT CHECK (status IN ('pending', 'confirmed', 'shipped', 'cancelled')),
amount NUMERIC(10,2) CHECK (amount > 0),
created_at TIMESTAMPTZ DEFAULT NOW(),
-- Exclude overlapping time ranges (PostgreSQL-specific)
EXCLUDE USING gist (customer_id WITH =, tsrange(created_at, shipped_at) WITH &&)
);
-- PostgreSQL: deferrable foreign keys
ALTER TABLE order_items
ADD CONSTRAINT fk_order FOREIGN KEY (order_id)
REFERENCES orders(id)
DEFERRABLE INITIALLY DEFERRED;
<code"># MySQL: historically weaker constraint enforcement # Silent truncation of values exceeding column length (strict mode off) # To get PostgreSQL-like strict mode: SET GLOBAL sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
Ecosystem Compatibility
| Tool / Framework | MySQL | PostgreSQL |
|---|---|---|
| WordPress | ✓ Default (MySQL required) | Possible with plugin (limited) |
| Laravel | ✓ Native support | ✓ Native support |
| Django | ✓ Native support | ✓ Better support (JSON, arrays) |
| Rails | ✓ Native support | ✓ Preferred (PostgreSQL features used by default) |
| Node.js (Sequelize) | ✓ Full support | ✓ Full support |
| Node.js (Prisma) | ✓ Full support | ✓ Full support (more features) |
| Strapi | ✓ Supported | ✓ Recommended for production |
| PostGIS (geospatial) | Not available | ✓ Best-in-class |
| TimescaleDB (time-series) | Not available | ✓ PostgreSQL extension |
| Supabase | Not available | ✓ PostgreSQL-based |
Install Both and Choose Per-Workload
On a VPS, there is no rule against running both — use PostgreSQL for complex analytical queries and MySQL for WordPress alongside it on the same server:
<code"># Install both on the same VPS apt install -y mysql-server postgresql-16 # MySQL for WordPress (because WordPress requires MySQL) # PostgreSQL for your custom application # Resource allocation — both running on 8 GB VPS: # MySQL: innodb_buffer_pool_size = 512M # PostgreSQL: shared_buffers = 1GB # Total DB RAM: ~2 GB — comfortable on 8 GB VPS
Migration: MySQL to PostgreSQL
For teams deciding to migrate an existing MySQL application to PostgreSQL:
<code"># pgloader — best tool for MySQL to PostgreSQL migration
apt install -y pgloader
# Migrate entire MySQL database to PostgreSQL
pgloader mysql://root:password@localhost/myapp \
postgresql://postgres:password@localhost/myapp
# pgloader handles:
# - Schema translation (data types, defaults)
# - Data migration with type casting
# - Index creation
# - Foreign key recreation
# Expected speed: 50,000–500,000 rows/second
Application code changes required after migration: update connection strings, change MySQL-specific syntax (backtick identifiers → double quotes, LIMIT x,y → LIMIT x OFFSET y), and replace MySQL-specific functions with PostgreSQL equivalents.
The Verdict for Most Asia-Pacific Applications
For new applications in 2026, PostgreSQL is the better default choice — the query planner is smarter, JSONB support handles semi-structured data elegantly, full-text search is built-in, and constraint enforcement catches data integrity bugs earlier. The ecosystem support is now equivalent to MySQL for all major frameworks.
Choose MySQL when: you are building on WordPress (MySQL-only), your team has deep MySQL expertise and no PostgreSQL experience, or you are integrating with a legacy system that requires MySQL specifically.
Conclusion
Both MySQL and PostgreSQL run excellently on a Hong Kong VPS — the performance difference for typical CRUD workloads is negligible on NVMe SSD with proper configuration. The meaningful differences emerge at the application level: PostgreSQL’s JSONB, full-text search, and sophisticated query planner provide capabilities that simplify application architecture. For teams starting fresh in 2026, PostgreSQL is the pragmatic choice; for WordPress-heavy deployments, MySQL remains the required option.
Run your database: Browse Server.HK Hong Kong VPS plans — NVMe SSD ensures both MySQL and PostgreSQL run at their best, with consistent I/O latency under load.