Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Denis Magda, Jimmy Angelakos

Rating No ratings yet

A learning path curated by Supabase from a selection of Manning books Postgres is more than a relational database, it's a powerful general-purpose platform that blends SQL elegance with practical features for modern applications. This complimentary eBook from Manning Publications & Supabase teaches you not only how to use Postgres, but how to use it well to its full extent: applying contemporary SQL techniques, leveraging built-in full-text capabilities, choosing appropriate data types, and avoiding common table and index design mistakes that cost performance and correctness. This eBook contains selected chapters from Manning titles Just Use Postgres! (by Denis Magda) and PostgreSQL Mistakes and How to Avoid Them (by Jimmy Angelakos) What's inside: Contemporary SQL techniques Built-in full-text capabilities Choosing appropriate data types Avoiding table and index design mistakes that cost performance and correctness

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
# Mastering PostgreSQL: Accelerate Your Weekend Projects and Seamlessly Scale to Millions ## 【One-Line Pitch】 A practical, hands-on guide curated by Supabase from two Manning books that teaches developers how to use PostgreSQL beyond basic CRUD—covering modern SQL techniques, full-text search, proper data types, and table/index design—so you can build efficient, scalable applications from weekend prototype to production. ## 【Book Arc】 - **Opening (~0%–10%)**: Introduces the book's premise—Postgres as a general-purpose platform, not just a relational database—and sets up the music streaming dataset used throughout, with Docker-based setup instructions for hands-on practice. - **Early (~10%–32%)**: Dives into modern SQL techniques, starting with CTEs (Common Table Expressions) for readable, maintainable queries, then progressing to data-modifying CTEs and recursive CTEs for hierarchical data like song sequences. - **Middle (~32%–48%)**: Covers window functions as a powerful alternative to self-joins and GROUP BY limitations, showing how to calculate running totals, rankings, and per-group aggregates while retaining row-level detail. - **Middle (~48%–60%)**: Explains PostgreSQL's built-in full-text search capabilities, walking through the tokenization, normalization, and indexing pipeline that transforms raw text into searchable lexemes. - **Late (~60%–85%)**: Addresses common data type mistakes—TIMESTAMP without time zone, CHAR(n), VARCHAR(n), MONEY, SERIAL, and XML—and when each causes correctness or performance problems. - **Ending (~85%–100%)**: Covers table and index design pitfalls, including table inheritance, partitioning strategies, and choosing the right index type for your workload. ## 【Key Takeaways】 - **CTEs improve readability without sacrificing performance** (Early): Postgres can fold CTEs into the primary query or materialize them when referenced multiple times, so you get cleaner SQL without paying a performance penalty. Use `MATERIALIZED` or `NON MATERIALIZED` to control behavior explicitly. - **Data-modifying CTEs execute concurrently** (Early): When a single query contains multiple CTEs that INSERT, UPDATE, or DELETE, changes from one CTE are not visible to others within the same query—a subtle but critical gotcha for writing correct multi-step operations. - **Recursive CTEs handle hierarchical data elegantly** (Early): Using `WITH RECURSIVE` with a base case and recursive step, you can traverse tree-like structures (like song sequences) with a level counter, replacing complex procedural logic with declarative SQL. - **Window functions solve problems self-joins can't** (Middle): `SUM() OVER (PARTITION BY ...)` lets you calculate aggregates across groups while keeping individual row detail—something impossible with plain GROUP BY. Any aggregate (AVG, MIN, COUNT) works as a window function, plus specialized ones for ranking and lag/lead analysis. - **Full-text search requires preprocessing** (Middle): Postgres tokenizes text into tokens, normalizes them into lexemes (stemming, removing stop words), and stores results in `tsvector` for indexed, fast searching—understanding this pipeline helps you design better search features. - **Data type choices have correctness implications** (Late): `TIMESTAMP WITHOUT TIME ZONE` can silently store wrong times across timezones, `CHAR(n)` pads with spaces, `MONEY` has rounding quirks, and `SERIAL` isn't a true data type—each has better alternatives depending on your use case. - **Table partitioning is often neglected but powerful** (Late): Proper partitioning can dramatically improve query performance and maintenance for large tables, but partitioning by multiple keys or using the wrong index type can negate those benefits. ## 【Reading Tips】 - **Set up the Docker environment early** (Opening–Early): The book uses a music streaming dataset throughout; cloning the repo and loading data into a Postgres container lets you run every example yourself, which is essential for internalizing the concepts. - **Deep-read the CTE and window function chapters** (Early–Middle): These are the most transferable skills for everyday SQL work. Pay special attention to the execution plans (`EXPLAIN ANALYZE`) to understand when Postgres folds vs. materializes CTEs. - **Skim the full-text search section** (Middle): The conceptual pipeline (tokenization → normalization → storage/indexing) is worth understanding, but you can skim the detailed implementation unless you're building search features. - **Use the data type chapter as a reference** (Late): Rather than reading cover-to-cover, treat it as a checklist—scan for the types you're currently using in your projects and read those sections carefully. - **Take away the decision framework** (Ending): The table/index mistakes chapter is most valuable as a set of "what not to do" rules; internalize the anti-patterns so you recognize them in your own schema designs. ## 【Coverage Limits】 This guide covers the book's core content on modern SQL, full-text search, data types, and table/index design. The excerpts do not include detailed coverage of Postgres installation, basic SQL syntax, or advanced performance tuning beyond what's mentioned in the table of contents. ##
Page 5
Box 761 Shelter Island, NY 11964 introduction introduction Postgres is more than a relational database, it's a powerful general-purpose platform that blend...
View in text
Page 12
.plays p JOIN streaming.songs s ON p.song_id = s.id WHERE p.play_start_time::DATE BETWEEN '2024-09-15' AND '2024-09-16' AND p.play_duration < (s.duration / 2...
View in text
Excerpt 3
us song. If the song is the first in the sequence, then its played_after column is set to NULL. Song sequences are an example of a hierarchical structure tha...
View in text
Excerpt 4
form lag-lead analysis by comparing different sets of data. Suppose our music streaming service needs to rank songs by their total play duration. The next li...
View in text
Excerpt 5
ault_text_search_config parameter. In our case, the default configuration is english. document—This parameter can be any text string or document from our ap...
View in text
Excerpt 6
cation UI. At the end of the day, our application should be prepared to handle minor grammatical errors and typos. If we want our application to recognize mi...
View in text
Excerpt 7
exemes | 'award':6 'chaotic':19 'contact':24 'demi':29 ➥ 'ghost':1,2,15 'help':22 'love':8 'moor':30 'oscar':5 ➥ 'patrick':11 'play':27 'psychic':20 ...
View in text
Excerpt 8
rds but no more than 10. The default values are 15 and 35. The FragmentDelimiter option allows customization of the delimiter that separates fragments. By d...
View in text
Tags
AI categories
SQLDatabaseBackend
Publish Year: 2026
Language: English
Pages: 116
File Format: PDF
File Size: 4.3 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…