| 140 | | </chapter> |
| 141 | | No newline at end of file |
| | 141 | |
| | 142 | <sect1> |
| | 143 | <title>Tuning your configuration</title> |
| | 144 | |
| | 145 | <para>These tips are taken from Kevin Neufeld's presentation "Tips for the |
| | 146 | PostGIS Power User" at the FOSS4G 2007 conference. Depending on your |
| | 147 | use of PostGIS (for example, static data and complex analysis vs frequently |
| | 148 | updated data and lots of users) these changes can provide significant |
| | 149 | speedups to your queries.</para> |
| | 150 | |
| | 151 | <para>For a more tips (and better formatting), the original presentation |
| | 152 | is at |
| | 153 | <ulink url="http://2007.foss4g.org/presentations/view.php?abstract_id=117"> |
| | 154 | http://2007.foss4g.org/presentations/view.php?abstract_id=117</ulink>. |
| | 155 | </para> |
| | 156 | |
| | 157 | <sect2> |
| | 158 | <title>Startup</title> |
| | 159 | |
| | 160 | <para> |
| | 161 | These settings are configured in postgresql.conf: |
| | 162 | </para> |
| | 163 | |
| | 164 | <para> |
| | 165 | checkpoint_segment_size |
| | 166 | </para> |
| | 167 | |
| | 168 | <itemizedlist> |
| | 169 | <listitem> |
| | 170 | <para> |
| | 171 | # of WAL files = 16MB each; default is 3 |
| | 172 | </para> |
| | 173 | </listitem> |
| | 174 | <listitem> |
| | 175 | <para> |
| | 176 | Set to at least 10 or 30 for databases with heavy write activity, or |
| | 177 | more for large database loads. |
| | 178 | </para> |
| | 179 | </listitem> |
| | 180 | <listitem> |
| | 181 | <para> |
| | 182 | Possibly store the xlog on a separate disk device |
| | 183 | </para> |
| | 184 | </listitem> |
| | 185 | </itemizedlist> |
| | 186 | |
| | 187 | <para> |
| | 188 | constraint_exclusion |
| | 189 | </para> |
| | 190 | |
| | 191 | <itemizedlist> |
| | 192 | <listitem> |
| | 193 | <para> |
| | 194 | Default: off |
| | 195 | </para> |
| | 196 | </listitem> |
| | 197 | <listitem> |
| | 198 | <para> |
| | 199 | Set to "on" to ensure the query planner will optimize as desired. |
| | 200 | </para> |
| | 201 | </listitem> |
| | 202 | </itemizedlist> |
| | 203 | |
| | 204 | <para> |
| | 205 | shared_buffers |
| | 206 | </para> |
| | 207 | |
| | 208 | <itemizedlist> |
| | 209 | <listitem> |
| | 210 | <para> |
| | 211 | Default: ~32MB |
| | 212 | </para> |
| | 213 | </listitem> |
| | 214 | <listitem> |
| | 215 | <para> |
| | 216 | Set to about 1/3 to 3/4 of available RAM |
| | 217 | </para> |
| | 218 | </listitem> |
| | 219 | </itemizedlist> |
| | 220 | </sect2> |
| | 221 | |
| | 222 | <sect2> |
| | 223 | <title>Runtime</title> |
| | 224 | |
| | 225 | <para> |
| | 226 | work_mem (the memory used for sort operations and complex queries) |
| | 227 | </para> |
| | 228 | |
| | 229 | <itemizedlist> |
| | 230 | <listitem> |
| | 231 | <para> |
| | 232 | Default: 1MB |
| | 233 | </para> |
| | 234 | </listitem> |
| | 235 | <listitem> |
| | 236 | <para> |
| | 237 | Adjust up for large dbs, complex queries, lots of RAM |
| | 238 | </para> |
| | 239 | </listitem> |
| | 240 | <listitem> |
| | 241 | <para> |
| | 242 | Adjust down for many concurrent users or low RAM. |
| | 243 | </para> |
| | 244 | </listitem> |
| | 245 | <listitem> |
| | 246 | <para> |
| | 247 | If you have lots of RAM and few developers: |
| | 248 | <programlisting> |
| | 249 | SET work_mem TO 1200000; |
| | 250 | </programlisting> |
| | 251 | </para> |
| | 252 | </listitem> |
| | 253 | </itemizedlist> |
| | 254 | |
| | 255 | <para> |
| | 256 | maintenance_work_mem (used for VACUUM, CREATE INDEX, etc.) |
| | 257 | </para> |
| | 258 | |
| | 259 | <itemizedlist> |
| | 260 | <listitem> |
| | 261 | <para> |
| | 262 | Default: 16MB |
| | 263 | </para> |
| | 264 | </listitem> |
| | 265 | <listitem> |
| | 266 | <para> |
| | 267 | Generally too low - ties up I/O, locks objects while swapping memory |
| | 268 | </para> |
| | 269 | </listitem> |
| | 270 | <listitem> |
| | 271 | <para> |
| | 272 | Recommend 32MB to 256MB on production servers w/lots of RAM, but depends |
| | 273 | on the # of concurrent users. If you have lots of RAM and few developers: |
| | 274 | <programlisting> |
| | 275 | SET maintainence_work_mem TO 1200000; |
| | 276 | </programlisting> |
| | 277 | </para> |
| | 278 | </listitem> |
| | 279 | </itemizedlist> |
| | 280 | |
| | 281 | </sect2> |
| | 282 | |
| | 283 | </sect1> |
| | 284 | </chapter> |
| | 285 | No newline at end of file |