Explore the World's Best Ideas
Join today and uncover 100+ curated journeys from 50+ topics. Unlock access to our mobile app with extensive features.
Postgres offers 3 textual data types, each with its own purpose, but offering the same query performance:
varchar and text can store strings that use up to 1GB, but if you want to change the limit of a varchar field, you have to rewrite the table. This process requires an exclusive lock on the table, meaning nobody can use it until the rewrite is complete.
9
48 reads
The basic unit of storage in Postgres is a page (or block). Each table and index is organized in 8KB logical pages, which are grouped into 1GB segments on disk. Whenever Postgres has to read a row from disk, it reads its physical location from the ctid column and then loads its entire corresponding page from disk.
9
44 reads
Materialized views (MV) are views that persist the results of their underlying query, can be refreshed periodically and let you add indexes on them. They're useful when you want to speed up an expensive query and you're ok working with stale data.
There are two ways to refresh a MV:
E.g. Naming convention: [app]_vw_[mv_name]_materialized
10
30 reads
The query planner looks at available indexes, cost settings, strategy settings, and distribution of data, in order to plan the most efficient way to execute a query.
Stats about the distribution of data are stored in the pg_statistic table and presented in a more readable form in the pg_stats view. They are generated based on ~20% of the table data (less for large tables) and are constantly updated by the autovacuum daemon. You can also manually update them using ANALYZE or VACUUM ANALYZE, the later which is strongly recommended after inserting or deleting a large number of rows.
9
22 reads
You can view a query plan using the EXPLAIN (ANALYZE, VERBOSE, BUFFERS) command. The plan is organized as a tree, where each node has these details:
10
29 reads
IDEAS CURATED BY
Alt account of @ocp. I use it to stash ideas about software engineering
Read & Learn
20x Faster
without
deepstash
with
deepstash
with
deepstash
Personalized microlearning
—
100+ Learning Journeys
—
Access to 200,000+ ideas
—
Access to the mobile app
—
Unlimited idea saving
—
—
Unlimited history
—
—
Unlimited listening to ideas
—
—
Downloading & offline access
—
—
Supercharge your mind with one idea per day
Enter your email and spend 1 minute every day to learn something new.
I agree to receive email updates