Inside SQLite, PostgreSQL, Browser AI, Web Automation and Modern Storage Engines
Introduction
Chapter 1: The Anatomy of a Database System
- The Database as a Stack: Layers from SQL to Silicon
- Core Responsibilities: Durability, Consistency, Concurrency, Availability
- The Storage Engine Contract: What the Query Processor Expects
- System vs Process: Database as Application vs Database as Operating System
- Performance as an Emergent Property
Chapter 2: Hardware Reality and Its Consequences
- CPU Cache Hierarchy and Locality: L1, L2, L3 and Working Set Size
- Memory Subsystem: Latency, Bandwidth and NUMA Effects
- Storage Media Physics: SSDs, NVMe, Rotational Disks and Persistent Memory
- I/O Patterns: Sequential, Random and Mixed Workloads
- Hardware-Aware Design Decisions
Chapter 3: The Mathematics and Statistics of Performance
- Latency Distributions: Mean, Median and Why They Lie
- Percentiles and Tail Latency: P99, P999 and What Matters
- Throughput and Saturation: Finding the Knee of the Curve
- Little’s Law and System Thinking
- Statistical Rigor: Repetition, Variance and Avoiding False Conclusions
Chapter 4: B-Trees and Their Variants
- B-Tree Fundamentals: Shape, Balance and Amortized Cost
- Page Structure and Node Layout
- Insertion, Deletion and Split Algorithms
- Search and Range Scan Mechanics
- Space Utilization and Fragmentation
Chapter 5: LSM Trees and Log-Structured Storage
- The LSM Invariant: Sequential Writes, Hierarchical Merge
- MemTable, SSTables and Flush Operations
- Compaction Strategies: Leveled, Size-Tiered and Hybrid
- Read Amplification and Bloom Filters
- Write-Ahead Logs in LSM Systems
Chapter 6: Page-Oriented Storage and Buffer Pools
- Page Format: Headers, Payloads and Free Space Maps
- The Buffer Pool: LRU, Clock and Adaptive Replacement
- Dirty Page Management and Write-Back
- Pinning, Latching and Concurrency Control in the Cache
- OS Page Cache vs Database Buffer Pool
Chapter 7: Write-Ahead Logging and Crash Recovery
- The Write-Ahead Logging Invariant
- Log Records, LSNs and Sequence Ordering
- Checkpointing: Full, Incremental and Archived
- ARIES and Modern Recovery Protocols
- Recovery Procedures: Analysis, Redo, Undo
Chapter 8: Transactions, MVCC and Isolation
- ACID as Implementation Constraints
- Two-Phase Locking and Deadlock Detection
- MVCC Snapshot Mechanics: Version Chains and Visibility
- Isolation Levels and Their Anomalies
- Serializable Execution: From 2PL to Snapshot Isolation
Chapter 9: SQLite Architecture Overview
- Design Philosophy: Zero Configuration and File-Based Isolation
- Codebase Layout and Build System
- The VDBE: Virtual Database Engine Architecture
- Memory Management: malloc, Page Cache and the Heap
- Threading Models and Mutex Strategies
Chapter 10: SQLite Storage and Page Format
- Database File Header: Version, Schema and Flags
- B-Tree Page Types: Interior, Leaf and Overflow
- Varint Encoding and Row Storage
- Cell Pointers and Free Byte Lists
- Schema Storage and the sqlite_master Table
Chapter 11: SQLite Transaction and Concurrency Model
- File Locking: UNIX flock and Windows LockFileEx
- Rollback Journal vs Write-Ahead Log
- WAL Checkpointing and Reader Blocking
- Mutex Hierarchies and Thread Safety
- SAVEPOINT and Nested Transaction Semantics
Chapter 12: SQLite Query Processing and Indexing
- Parsing and Bytecode Generation
- The VDBE OpCodes and Execution Flow
- Index Selection Heuristics and Cost Estimation
- Co-routine Queries and Subqueries
- EXPLAIN and EXPLAIN QUERY PLAN Analysis
Chapter 13: PostgreSQL Architecture Overview
- Process Model: Postmaster, Backend and Shared Memory
- Shared Buffers and the Buffer Manager
- Background Workers: Autovacuum, Writer, Checkpointer
- Configuration Architecture and GUCs
- Extension System and Custom Storage Engines
Chapter 14: PostgreSQL Storage and Indexing
- Heap Page Layout and Tuple Structure
- Item Pointers and TOAST Compression
- B-Tree Index Internals and Vacuum Interaction
- GiST and GIN: Generalized Search Structures
- BRIN: Block Range Indexes for Large Tables
Chapter 15: PostgreSQL MVCC and Transaction System
- Transaction IDs and Subtransactions
- Visibility Rules and Snapshot Construction
- Dead Tuples and Bloat
- Autovacuum Scheduling and Configuration
- XID Wraparound and Emergency Vacuum
Chapter 16: PostgreSQL Concurrency and Locking
- The Lock Manager: Hash Tables and Lock Queues
- Lock Types and Granularities
- Row-Level Locks and Key-Share Conflicts
- Deadlock Detection Algorithm
- Nowait, Skip Locked and Conflict Resolution
Chapter 17: PostgreSQL Query Optimizer and Execution
- Parser, Rewriter and Planner Pipeline
- Path Types and Cost Estimation
- Join Algorithms: Nested Loop, Hash and Merge
- Parallel Query Execution
- EXPLAIN ANALYZE and Plan Interpretation
Chapter 18: Query Parsing, Planning and Cost Models
- The Parsing Pipeline: Lexing to Logical Plans
- Logical Optimization: Predicates Pushdown and Join Reordering
- Cost Models: Selectivity, Cardinality and I/O Estimates
- Statistics Collection and Histograms
- Plan Cache and Parameter Sniffing
Chapter 19: Join Algorithms and Their Tradeoffs
- Nested Loop Joins: Simple and Index-Assisted
- Hash Joins: Build, Probe and Spill
- Merge Joins: Sorted Inputs and External Merge
- Join Order Optimization and Join Trees
- Skew and Anti-Patterns
Chapter 20: Aggregation, Sorting and Window Functions
- Hash Aggregation and Sort Aggregation
- External Sorting: Tiling and Merging
- Window Functions: Frame Semantics and Memory
- Approximate Aggregations and Sketches
- Materialized Views and Incremental Maintenance
Chapter 21: Benchmarking Methodologies and Workload Characterization
- Benchmark Design: Microbenchmarks vs End-to-End
- Workload Generation: TPC, YCSB and Custom Patterns
- Warmup, Steady State and Run Length
- Controlling Variables and Reproducibility
- Common Benchmark Fallacies and How to Avoid Them
Chapter 22: Profiling, Tracing and Observability
- CPU Profiling: Flame Graphs and Sampling
- I/O Tracing: blktrace, iostat and SystemTap
- Database-Specific Tracing and Logs
- eBPF and Kernel-Level Observability
- Metrics Architecture and Alerting
Chapter 23: Diagnosing and Resolving Performance Problems
- The Diagnostic Methodology: Symptom to Hypothesis
- Slow Queries and Bad Plans
- Lock Contention and Blocking Chains
- Memory Pressure and Swap
- Disk Saturation and I/O Bottlenecks
Chapter 24: Designing for Performance from the Start
- Schema Design for Performance: Normalization vs Denormalization
- Indexing Strategy: Types, Selectivity and Maintenance Cost
- Partitioning and Sharding Strategies
- Caching Layers: In-Memory, Query and Application-Level
- Connection Management and Pooling
Chapter 25: Browser Architecture and Automation Fundamentals
- Browser Internals: Rendering, Compositing and Scripting
- The DOM and Accessibility Trees
- DevTools Protocol: Commands, Events and Streaming
- Headless Browsers: Chromium, Firefox and Isolation
- Browser Extensions as Automation Vectors
Chapter 26: AI-Powered Browser Agents
- Agent Architecture: Perceive, Plan, Act, Observe
- DOM as an Environment for Agents
- Tool Calling and Function Execution
- Multi-Agent Orchestration and Task Decomposition
- Reliability Patterns: Retry, Verification and Rollback
Chapter 27: Web Automation Frameworks and Data Extraction
- Playwright, Selenium and Puppeteer: Architecture and Tradeoffs
- DOM Scraping and Structured Extraction
- Handling Dynamic Content and JavaScript-Rendered Pages
- Authentication, Sessions and Browser Contexts
- Rate Limiting, Fingerprinting and Ethics
Chapter 28: Integrating Browser Agents with Database Systems
- Architecture Patterns: Agent, API and Database
- Data Extraction Pipelines to Database Storage
- Transaction Boundaries and Atomicity
- Authentication, Authorization and Security
- Monitoring, Logging and Operational Concerns
Chapter 29: Production Workflows and End-to-End Implementations
- Complete Reference Implementation: Architecture Overview
- Agent Configuration and Prompt Engineering
- Database Schema Design for Agent Data
- Error Handling, Recovery and Idempotency
- Performance Tuning the Full Stack
Chapter 30: Synthesis and Future Directions
- Key Principles Summarized
- Where Databases Are Heading: HTAP, Vector and Beyond
- Persistent Memory and New Storage Paradigms
- AI-Driven Database Management
- The Engineer’s Checklist for Database Performance