Adding 'Optimizing PostgreSQL settings' sub-section.
All checks were successful
Deploy Greenlight API / deploy (push) Successful in 54s
All checks were successful
Deploy Greenlight API / deploy (push) Successful in 54s
This commit is contained in:
21
README.md
21
README.md
@@ -181,4 +181,23 @@ _A panic typically means something went unexpectedly wrong. Mostly we use it to
|
|||||||
**json.MarshalIndent()** takes 65% longer to run and uses around 30% more memory than **json.Marshal()**, as well as making two more heap allocations. Those figures will change depending on what you're encoding, but they're fairly indicative of the performance impact.
|
**json.MarshalIndent()** takes 65% longer to run and uses around 30% more memory than **json.Marshal()**, as well as making two more heap allocations. Those figures will change depending on what you're encoding, but they're fairly indicative of the performance impact.
|
||||||
|
|
||||||
For most applications this performance difference simply isn't something that you need to worry about. In real terms, we're talking about a few thousandths of a millisecond - and the improved readability of responses is probably worth this trade-off.
|
For most applications this performance difference simply isn't something that you need to worry about. In real terms, we're talking about a few thousandths of a millisecond - and the improved readability of responses is probably worth this trade-off.
|
||||||
But if your API is operating in a very resource-constrained environment, or needs to manage extremely high levels of traffic, then this is worth being aware of, and you may prefer to stick with using **json.Marshal()** instead.
|
But if your API is operating in a very resource-constrained environment, or needs to manage extremely high levels of traffic, then this is worth being aware of, and you may prefer to stick with using **json.Marshal()** instead.
|
||||||
|
|
||||||
|
#### Optimizing PostgreSQL settings
|
||||||
|
|
||||||
|
The default settings that PostgreSQL ships with are quite conservative, and you can often improve the performance of your database by tweaking the values in your **postgresql.conf** file.
|
||||||
|
|
||||||
|
You can check where your **postgresql.conf** file lives with the following SQL query :
|
||||||
|
|
||||||
|
``` postgresql
|
||||||
|
$ sudo -u postgres psql -c 'SHOW config_file;'
|
||||||
|
----------------------------------------------
|
||||||
|
/etc/postgresql/15/main/postgresql.conf
|
||||||
|
(1 row)
|
||||||
|
```
|
||||||
|
|
||||||
|
To read more about PostgreSQL optimization :
|
||||||
|
https://www.enterprisedb.com/postgres-tutorials/how-tune-postgresql-memory
|
||||||
|
|
||||||
|
To generate suggested values based on your available system hardware, you can use :
|
||||||
|
https://pgtune.leopard.in.ua
|
||||||
Reference in New Issue
Block a user