Topic 24 of

MySQL vs PostgreSQL vs BigQuery — Which to Learn?

MySQL, PostgreSQL, and BigQuery are the three SQL databases you'll encounter most in Indian tech companies. Here's what's different — and which to learn first.

📚Beginner
⏱️9 min
5 quizzes
🗺️

The Landscape — OLTP vs OLAP

Before comparing specific databases, understand the two categories:

OLTP (Online Transaction Processing) — MySQL, PostgreSQL

  • Many small, fast read/write operations
  • Row-by-row inserts and updates
  • Powers production applications: user signups, order placement, payment processing
  • Think: Flipkart's order database, PhonePe's transaction logs

OLAP (Online Analytical Processing) — BigQuery, Snowflake, Redshift

  • Few, complex, read-heavy analytical queries
  • Scans millions of rows for aggregation and reporting
  • Powers analytics: dashboards, business intelligence, data science
  • Think: Swiggy's weekly revenue reports, Zomato's restaurant performance analytics

Most data analysts work with both: PostgreSQL or MySQL for transactional data exports, BigQuery or Snowflake for warehousing and large-scale analytics.

🐬

MySQL — The Workhorse

MySQL is the most widely deployed open-source database. If a startup is building a product, there's a 70% chance it's on MySQL.

What Makes MySQL Different

Pros:

  • Simple and fast for basic operations — great for small to medium workloads
  • Massive ecosystem — tools, hosting, documentation everywhere
  • Easy to learn — the simplest SQL dialect for beginners
  • Cost-effective — runs on cheap hardware, minimal tuning needed

Cons:

  • Limited advanced SQL features — no CTEs until version 8.0, weak window functions
  • Poor at complex queries — slow for multi-table joins or analytical workloads
  • Storage engines matter — MyISAM (old, no transactions) vs InnoDB (modern, transactional)

Typical Use Cases

  • Web application backends: WordPress, Shopify stores, SaaS products
  • E-commerce platforms: small to mid-size online stores
  • Content management systems

Indian Companies Using MySQL

Flipkart (early days), Paytm, MakeMyTrip, most Indian SaaS startups

Key Syntax Differences

query.sqlSQL
-- Date handling: MySQL specific
SELECT DATE_FORMAT(order_date, '%Y-%m') AS month FROM orders;

-- String concatenation
SELECT CONCAT(first_name, ' ', last_name) AS full_name FROM customers;

-- Limit syntax
SELECT * FROM orders ORDER BY order_date DESC LIMIT 10;

-- Auto-increment primary key
CREATE TABLE users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  email VARCHAR(255)
);

⚠️ CheckpointQuiz error: Missing or invalid options array

🐘

PostgreSQL — The Feature-Rich Powerhouse

PostgreSQL (often called "Postgres") is the most advanced open-source relational database. It's MySQL's more sophisticated sibling.

What Makes PostgreSQL Different

Pros:

  • Full SQL standard support — CTEs, window functions, recursive queries, advanced joins
  • Extensibility — custom functions, operators, data types; extensions like PostGIS (geospatial)
  • Strong data integrity — ACID compliance, foreign keys enforced properly
  • Better for complex queries — query planner is smarter than MySQL's
  • JSON support — native JSONB type for semi-structured data

Cons:

  • Steeper learning curve — more configuration options, more complex
  • Slower for simple operations — MySQL wins for basic inserts/selects at small scale
  • Less common in Indian startups — smaller ecosystem compared to MySQL

Typical Use Cases

  • Data-intensive applications with complex queries
  • Geospatial applications (PostGIS extension)
  • Applications needing advanced SQL features (CTEs, window functions)
  • Data pipelines and ETL processes

Indian Companies Using PostgreSQL

Razorpay, CRED, Zerodha, Dunzo, larger tech companies moving from MySQL

Key Syntax Differences from MySQL

query.sqlSQL
-- Date truncation: PostgreSQL specific
SELECT DATE_TRUNC('month', order_date) AS month FROM orders;

-- String concatenation: || operator
SELECT first_name || ' ' || last_name AS full_name FROM customers;

-- Limit and offset
SELECT * FROM orders ORDER BY order_date DESC LIMIT 10 OFFSET 20;

-- Auto-increment: SERIAL type
CREATE TABLE users (
  id SERIAL PRIMARY KEY,
  email VARCHAR(255)
);

-- JSON support
SELECT data->>'name' AS name FROM events WHERE data @> '{"type": "purchase"}';

-- CTEs (both support now, but Postgres had it first)
WITH monthly_sales AS (
  SELECT DATE_TRUNC('month', order_date) AS month, SUM(amount) AS revenue
  FROM orders GROUP BY 1
)
SELECT * FROM monthly_sales WHERE revenue > 100000;
☁️

BigQuery — The Analytics Warehouse

BigQuery is Google's fully-managed, serverless data warehouse. It's not a database you "install" — it's a cloud service you use.

What Makes BigQuery Different

Pros:

  • Petabyte scale — query billions of rows in seconds
  • Pay-per-query — no servers to manage, only pay for queries you run
  • Columnar storage — optimized for analytics (aggregations, scans)
  • Native integrations — Google Analytics 4, Firebase, Looker Studio
  • Standard SQL — mostly ANSI SQL compliant with useful extensions

Cons:

  • Expensive — queries cost ₹400–800 per TB scanned; large queries add up fast
  • Not for transactional workloads — no row-level updates/deletes at scale
  • Vendor lock-in — you can't move BigQuery to another cloud easily
  • Learning curve — partitions, clustering, nested/repeated fields

Typical Use Cases

  • Data warehousing: centralizing data from multiple sources
  • Business intelligence dashboards: Looker, Data Studio, Tableau
  • Log analytics: analyzing millions of app events, clickstreams
  • Marketing analytics: Google Analytics 4 data, ad performance

Indian Companies Using BigQuery

Swiggy, Zomato, PhonePe, Ola, Meesho — any company with massive event data

Key Syntax Differences

query.sqlSQL
-- Date functions: BigQuery specific
SELECT FORMAT_DATE('%Y-%m', order_date) AS month FROM orders;
SELECT DATE_TRUNC(order_date, MONTH) AS month FROM orders;

-- Backticks for table names (required for project.dataset.table)
SELECT * FROM `project-id.dataset_name.table_name`;

-- UNNEST for arrays
SELECT order_id, item
FROM orders, UNNEST(items) AS item;

-- STRUCT for nested data
SELECT
  customer_id,
  STRUCT(name, email, phone) AS customer_info
FROM customers;

-- Standard SQL window functions (same as PostgreSQL mostly)
SELECT customer_id,
  ROW_NUMBER() OVER (PARTITION BY city ORDER BY total_orders DESC) AS rank_in_city
FROM customer_summary;

-- Cost control: limit scanned data with WHERE on partitioned columns
SELECT * FROM orders
WHERE DATE(order_date) BETWEEN '2026-01-01' AND '2026-03-31';
-- Filters by partition, scans less data, costs less

Cost Management Tips

  1. Partition tables by date — queries that filter by date only scan relevant partitions
  2. Cluster tables — group similar rows together for faster scans
  3. Use _TABLE_SUFFIX for sharded tables — query only specific date ranges
  4. Avoid SELECT * — specify columns to reduce data scanned
  5. Use query caching — BigQuery caches results for 24 hours (free)
⚖️

Side-by-Side Comparison

| Feature | MySQL | PostgreSQL | BigQuery | |---------|-------|------------|----------| | Type | OLTP | OLTP | OLAP | | Best for | Web apps, simple queries | Complex queries, data integrity | Large-scale analytics | | Scale | GBs to TBs | GBs to TBs | TBs to PBs | | Cost | Cheap (self-hosted) | Cheap (self-hosted) | Pay-per-query | | Window functions | Yes (8.0+) | Excellent | Excellent | | CTEs | Yes (8.0+) | Yes | Yes | | JSON support | Basic | Excellent (JSONB) | Good (nested) | | Learning curve | Easy | Medium | Medium | | Common in India | Very common | Growing | Common at scale |

Which to Learn First?

For absolute beginners: Start with MySQL. It's the simplest, most forgiving, and you'll encounter it in every small company.

For data analysts: Learn PostgreSQL or BigQuery depending on company size:

  • PostgreSQL if working at mid-size startups (10–500 people)
  • BigQuery if working at scale-ups/large companies (500+ people)

The good news: 90% of SQL syntax is identical across all three. If you know one, you can work with the others within a week.

What Transfers Between Them

100% transferable:

  • SELECT, WHERE, GROUP BY, HAVING, ORDER BY
  • JOINs (INNER, LEFT, RIGHT, FULL)
  • Aggregate functions (COUNT, SUM, AVG, MIN, MAX)
  • Window functions (ROW_NUMBER, RANK, LAG, LEAD)
  • CTEs (WITH clause)

Slightly different:

  • Date functions (DATE_FORMAT vs DATE_TRUNC vs FORMAT_DATE)
  • String concatenation (CONCAT() vs ||)
  • Limit syntax (LIMIT vs LIMIT OFFSET)

Database-specific:

  • BigQuery: UNNEST, STRUCT, partitions, clustering
  • PostgreSQL: JSONB, PostGIS, custom types
  • MySQL: storage engines (InnoDB vs MyISAM)

⚠️ FinalQuiz error: Missing or invalid questions array

⚠️ SummarySection error: Missing or invalid items array

Received: {"hasItems":false,"isArray":false}