\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{armk} \pdfinfo{ /Title (postgresql-settings-config-quick-reference.pdf) /Creator (Cheatography) /Author (armk) /Subject (Postgresql settings/config quick reference Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{336791} \definecolor{LightBackground}{HTML}{F2F5F8} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Postgresql settings/config quick reference Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{armk} via \textcolor{DarkBackground}{\uline{cheatography.com/215747/cs/47043/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}armk \\ \uline{cheatography.com/armk} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 19th September, 2025.\\ Updated 19th September, 2025.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{The config file(s)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Main config file is {\bf{postgresql.conf}} in instance directory (or specified explicitly as startup argument). \newline % Row Count 3 (+ 3) Settings changes (incl. ALTER SYSTEM) are often not applied immediately: see the context property for how/when setting changes are applied. \newline % Row Count 6 (+ 3) Official doc: \{\{link="https://www.postgresql.org/docs/current/config-setting.html"\}\}19.1. Setting Parameters\{\{/link\}\} / \{\{link="https://www.postgresql.org/docs/current/view-pg-settings.html\#VIEW-PG-SETTINGS"\}\}52.24. pg\_settings\{\{/link\}\}% Row Count 11 (+ 5) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.8 cm} x{5.2 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Connection/network}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{listen\_addresses} & interfaces to listen on (ipv4 and v6) \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} port & TCP port \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} \seqsplit{max\_connections} & Max simultaneous sessions \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} ssl & Enable encrypted transport \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.92 cm} x{4.08 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Logging}} \tn % Row 0 \SetRowColor{LightBackground} log\_destination & Log format \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} log\_filename & Log filename pattern \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} log\_min\_messages & Minimum event severity to be logged \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{log\_min\_duration\_statement} & Log all statements with exec time \textgreater{} value \tn % Row Count 7 (+ 3) % Row 4 \SetRowColor{LightBackground} log\_checkpoint & Log checkpoints \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} log\_line\_prefix & Prefix for all log lines \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} log\_lock\_waits & Log lock waits longer than value \tn % Row Count 12 (+ 2) % Row 7 \SetRowColor{white} log\_statement & Log SQL statements (DML only, DDL only, ...) \tn % Row Count 15 (+ 3) % Row 8 \SetRowColor{LightBackground} log\_temp\_files & Log temp files larger than value \tn % Row Count 17 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{See \{\{link="https://www.postgresql.org/docs/current/runtime-config-logging.html\#RUNTIME-CONFIG-LOGGING"\}\}19.8. Error Reporting and Logging\{\{/link\}\} for filename format and templates} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{WAL/checkpoints}} \tn % Row 0 \SetRowColor{LightBackground} wal\_level & Transaction log level: minimal (no log), replica, logical \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} fsync & Force flushing OS disk cache to physical storage \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} wal\_sync\_method & Method used for forcing WAL updates out to disk when fsync is on \tn % Row Count 10 (+ 4) % Row 3 \SetRowColor{white} synchronous\_commit & Wait for writes to be committed to disk before sending commit to client \tn % Row Count 14 (+ 4) % Row 4 \SetRowColor{LightBackground} full\_page\_writes & Do not write partial pages to WAL \tn % Row Count 16 (+ 2) % Row 5 \SetRowColor{white} wal\_buffers & Size of WAL buffers in RAM \tn % Row Count 18 (+ 2) % Row 6 \SetRowColor{LightBackground} checkpoint\_timeout & Max delay between checkpoints \tn % Row Count 20 (+ 2) % Row 7 \SetRowColor{white} \seqsplit{checkpoint\_completion\_target} & Spread checkpoint over n times checkpoint\_timeout \tn % Row Count 23 (+ 3) % Row 8 \SetRowColor{LightBackground} min/max\_wal\_size & Soft limits (targets) for WAL size \tn % Row Count 25 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.36 cm} x{4.64 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Replication}} \tn % Row 0 \SetRowColor{LightBackground} archive\_mode & Enable WAL archiving \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \seqsplit{archive\_command} & Command used to archive WAL files \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{max\_wal\_senders} & Max concurrent replication threads \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} wal\_keep\_size & Size of preserved WAL segments {\bf{on the primary}} \tn % Row Count 8 (+ 3) % Row 4 \SetRowColor{LightBackground} \seqsplit{max\_replication\_slots} & Number of replication slots (max concurrent standby connections) \tn % Row Count 11 (+ 3) % Row 5 \SetRowColor{white} hot\_standby & When in standby (in recovery), accept connections \tn % Row Count 14 (+ 3) % Row 6 \SetRowColor{LightBackground} \seqsplit{hot\_standby\_feedback} & When in standby, give status feedback to primary \tn % Row Count 17 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{See \{\{link="https://www.postgresql.org/docs/current/runtime-config-wal.html\#RUNTIME-CONFIG-WAL-SETTINGS"\}\}19.5.1. Write Ahead Log settings\{\{/link\}\}, \{\{link="https://www.postgresql.org/docs/current/continuous-archiving.html\#BACKUP-ARCHIVING-WAL"\}\}25.3.1. Setting Up WAL Archiving\{\{/link\}\} and \{\{link="https://www.postgresql.org/docs/current/runtime-config-replication.html\#RUNTIME-CONFIG-REPLICATION"\}\}19.6. Replication\{\{/link\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.28 cm} x{4.72 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Resources}} \tn % Row 0 \SetRowColor{LightBackground} shared\_buffers & Instance-wide shared memory (see oracle sga) \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} temp\_buffers & Dedicated memory per session (see oracle pga) \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} work\_mem & Dedicated memory per query \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{maintenance\_work\_mem} & Memory reserved for maintenance ops (vacuum, index creation, etc) \tn % Row Count 9 (+ 3) % Row 4 \SetRowColor{LightBackground} \seqsplit{autovacuum\_work\_mem} & Memory dedicated to autovacuum processes \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Autovacuum controls}} \tn % Row 0 \SetRowColor{LightBackground} autovacuum & Enable/disable autovacuum \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{autovacuum\_max\_workers} & Max parallel autovac jobs \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} autovacuum\_naptime & Max delay before autovac \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{autovacuum\_vacuum\_cost\_limit} & Accumulated I/O cost of autovac before pausing \tn % Row Count 9 (+ 3) % Row 4 \SetRowColor{LightBackground} \seqsplit{autovacuum\_vacuum\_cost\_delay} & Duration of autovacuum pause (see previous) \tn % Row Count 12 (+ 3) % Row 5 \SetRowColor{white} \seqsplit{autovacuum\_vacuum\_threshold} & Insert/update threshold to trigger autovac (absolute) \tn % Row Count 15 (+ 3) % Row 6 \SetRowColor{LightBackground} \seqsplit{autovacuum\_vacuum\_scale\_factor} & Insert/update threshold to trigger autovac (relative) \tn % Row Count 18 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{See \{\{link="https://www.postgresql.org/docs/current/runtime-config-autovacuum.html\#RUNTIME-CONFIG-AUTOVACUUM"\}\}19.10. Automatic Vacuuming\{\{/link\}\} \newline Autovacuum keeps count of I/O (as "cost"). Once cost has reached \seqsplit{autovacuum\_vacuum\_cost\_limit}, it pauses for \seqsplit{autovacuum\_vacuum\_cost\_delay}. \newline Vacuum threshold is the sum of vacuum\_threshold and vacuum\_scale\_factor. \newline Autovacuum trigger thresholds have separate, identical parameters for inserts.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.76 cm} x{4.24 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Planner/optimizer}} \tn % Row 0 \SetRowColor{LightBackground} seq\_page\_cost & Sequential page read cost \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{random\_page\_cost} & Random page read cost \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{cpu\_operator\_cost} & Operator call cost \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{effective\_cache\_size} & Estimated system cache size \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \seqsplit{default\_statistics\_target} & "Target quality" of the optimizer: higher values takes longer to calculate plan but yields better results \tn % Row Count 14 (+ 6) % Row 5 \SetRowColor{white} \seqsplit{from\_collapse\_limit} & Merge nested FROM (to avoid "reorder experimentation" from the planner) if sub-FROM would yield less than this setting \tn % Row Count 21 (+ 7) % Row 6 \SetRowColor{LightBackground} \seqsplit{join\_collapse\_limit} & See \seqsplit{from\_collapse\_limit} but with JOINs instead of FROMs \tn % Row Count 24 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{See \{\{link="https://www.postgresql.org/docs/current/runtime-config-query.html\#RUNTIME-CONFIG-QUERY"\}\}19.7. Query Planning\{\{/link\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}