TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Practical Guide to PostgreSQL Optimizations

124 pointsby omarishover 8 years ago

5 comments

sbuttgereitover 8 years ago
The work_mem section is incorrect. The article says the configuration is per worker, but it&#x27;s actually per operation which requires work_mem... any given worker can have multiple operations running in parallel. So actually getting a good, but safe, value is more sensitive than the article suggests.<p><a href="https:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;9.5&#x2F;static&#x2F;runtime-config-resource.html#GUC-WORK-MEM" rel="nofollow">https:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;9.5&#x2F;static&#x2F;runtime-config-re...</a><p><i>work_mem (integer)<p>Specifies the amount of memory to be used by internal sort operations and hash tables before writing to temporary disk files. The value defaults to four megabytes (4MB). Note that for a complex query, several sort or hash operations might be running in parallel; each operation will be allowed to use as much memory as this value specifies before it starts to write data into temporary files. Also, several running sessions could be doing such operations concurrently. Therefore, the total memory used could be many times the value of work_mem; it is necessary to keep this fact in mind when choosing the value. Sort operations are used for ORDER BY, DISTINCT, and merge joins. Hash tables are used in hash joins, hash-based aggregation, and hash-based processing of IN subqueries.</i>
评论 #12353601 未加载
评论 #12354085 未加载
ceyhunkazelover 8 years ago
I recommend following Christophe Pettus - PostgreSQL Proficiency for Python People - PyCon 2016 video for postgresql basics and optimization<p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=knUitQQnpJo" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=knUitQQnpJo</a>
评论 #12353965 未加载
pellaover 8 years ago
simple tool: <a href="http:&#x2F;&#x2F;pgtune.leopard.in.ua&#x2F;" rel="nofollow">http:&#x2F;&#x2F;pgtune.leopard.in.ua&#x2F;</a>
评论 #12354354 未加载
评论 #12354345 未加载
评论 #12354439 未加载
DrJokepuover 8 years ago
SHMMAX basically stopped being an important factor in PostgreSQL 9.3 (released almost 3 years ago) and later.
olalondeover 8 years ago
I&#x27;m currently reading &quot;Designing Data-Intensive Applications&quot; by Martin Kleppman and it has an interesting chapter on database storage engines, including PostgreSQL (e.g. B-trees chapter). I would definitely recommend if you&#x27;d like a high level overview of how things work under the hood (it&#x27;s a good mix of theory and practice). It also helps understanding why and when optimisations work.