Comments (5)
Hi @le0pard,
a safe change for everyone would be this:
if SSD:
random_page_cost = 1.1
else
random_page_cost = 4
Technically the only thing it changes is Postgres using indexes more eagerly, affecting only planner, so nothing to benchmark - some plans query plans switch to using indexes. random_page_cost basically says
"you'd better read 4x more data sequentially than read it by random index scan".
Setting random_page_cost = 1.1
on SSD is pretty modest change. Further tweaking for system may get it lower, down to seq_page_cost
.
Changing seq_page_cost
is not normally necessary, what matters is ratio between random and seq scan - you need to get data from disk, and you'll get it either randomly reading or sequentially reading :)
This change is critical for anyone who uses PostGIS as their index operations are much faster than on-disk operations, and there is currently no way in Postgres to inform planner about it.
It's currently number one reason for "why are my indexes not being used?!" when debugging someone's query in https://t.me/pgsql. Setting 1.1 usually solves issues.
Postgres developers recommend going as low as 1.0: http://www.sai.msu.su/~megera/postgres/talks/Everything-Indexes-v4.pdf
from pgtune.
@dewey so still not clear what the math model?
if SSD
random_page_cost = ??? # does memory, cpu influence?
seq_page_cost = ??? # does memory, cpu influence?
else
random_page_cost = ??? # does memory, cpu influence?
seq_page_cost = ??? # does memory, cpu influence?
from pgtune.
I don't know enough about performance tuning to suggest values. I just came across your tool and the article at the same time and figured it would be a good match to be included.
If there's nobody who can give a bit more background information you could also just add a selector for the disk and if SSD is suggested link to the blog post or Postgres documentation about random_page_cost
and seq_page_cost
. Judging by the comments on HN (https://news.ycombinator.com/item?id=15761026) a lot of people didn't know about these values in the first place.
One data point from there is:
Setting random_page_cost = 1 is pretty common advice for SSD and works well in my experience. Typical advice for HDD RAID or SCSI is random_page_cost = 2 and SSDs are faster than them.
from pgtune.
@dewey so this mean, we do not have benchmark for random_page_cost
and seq_page_cost
(because by this numbers we can create math model and add it to pgtune). By "feeling" can give wrong values and create problem for using pgtune tool, because "do no harm" main point for it.
from pgtune.
@Komzpa Thanks, added in pgtune. You can check with @dewey :)
from pgtune.
Related Issues (20)
- work_mem when max_worker_processes used HOT 2
- Site 404 HOT 2
- Support Postgres 12 HOT 1
- Feedback from HN HOT 5
- Api to integrate with configuration tools like ansible? HOT 2
- NVME SSD Settings HOT 1
- Shared_buffers for Windows
- # WARNING this tool not being optimal for very high memory systems HOT 1
- Same in Odoo configuration. HOT 6
- parallel worker settings seem wrong in the 2 CPU case HOT 2
- Support Postgresql 15 HOT 4
- maintenance work memory is outside of the valid range HOT 2
- pg 15 HOT 2
- Show AWS RDS Config Style HOT 4
- Container options, especially shm-size HOT 4
- Does effective_io_concurrency need to be set differently for PostgreSQL 13+? HOT 3
- Estimate number of hugepages needed for larger systems. HOT 2
- Ruby bundle is actual? HOT 1
- Hi HOT 1
- apt package HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pgtune.