Обсуждение: Re: how to do profile for pg?

Поиск
Список
Период
Сортировка

Re: how to do profile for pg?

От
Aleksander Alekseev
Дата:
Hi jacktby,

PostgreSQL is literally a large and complicated program in C. Thus it
can be profiled as such. E.g. you can use `perf` and build flamegraphs
using `perf record`. Often pgbench is an adequate tool to compare
before and after results.There are many other tools available
depending on what exactly you want to profile - CPU, lock contention,
disk I/O, etc. People write books (plural) on the subject. Personally
I would recommend "System Performance, Enterprise and the Cloud, 2nd
Edition" and "BPF Performance Tools" by Brendan Gregg.

-- 
Best regards,
Aleksander Alekseev



Re: how to do profile for pg?

От
"jacktby@gmail.com"
Дата:
but I need a quick demo to see the memory profiling or CPU profiling.  I hope a blog or a video which is better for me. Thanks.


---- Replied Message ----
Hi jacktby,

PostgreSQL is literally a large and complicated program in C. Thus it
can be profiled as such. E.g. you can use `perf` and build flamegraphs
using `perf record`. Often pgbench is an adequate tool to compare
before and after results.There are many other tools available
depending on what exactly you want to profile - CPU, lock contention,
disk I/O, etc. People write books (plural) on the subject. Personally
I would recommend "System Performance, Enterprise and the Cloud, 2nd
Edition" and "BPF Performance Tools" by Brendan Gregg.

--
Best regards,
Aleksander Alekseev

Re: how to do profile for pg?

От
Aleksander Alekseev
Дата:
Hi,

> but I need a quick demo to see the memory profiling or CPU profiling.  I hope a blog or a video which is better for
me.Thanks
 

Well, then I guess you better hurry with reading these books :)

There is no shortcut I'm afraid. One of the first things that Brendan
explains is how to do benchmarks *prorerly*. This is far from being
trivial and often you may be measuring not something you want. E.g.
you may think that you are profiling CPU while in fact there is a lock
contention and CPU is not even a bottleneck. Another thing worth
considering which is often neglected is to make sure your optimization
doesn't cause any digradations under different workloads.

Last but not least you should be mindful of different configuration
parameters of PostgreSQL - shared_buffers, synchronous_commit = off,
to name a few, and also understand the architecture of the system
quite well. In this context I recommend Database System Concepts, 7th
Edition by Avi Silberschatz et al and also CMU Intro to Database
Systems [1] and CMU Advanced Database Systems [2] courses.

[1]: https://www.youtube.com/playlist?list=PLSE8ODhjZXjZaHA6QcxDfJ0SIWBzQFKEG
[2]: https://www.youtube.com/playlist?list=PLSE8ODhjZXjYzlLMbX3cR0sxWnRM7CLFn

-- 
Best regards,
Aleksander Alekseev