Book Image

PostgreSQL High Performance Cookbook

By : Chitij Chauhan, Dinesh Kumar
Book Image

PostgreSQL High Performance Cookbook

By: Chitij Chauhan, Dinesh Kumar

Overview of this book

PostgreSQL is one of the most powerful and easy to use database management systems. It has strong support from the community and is being actively developed with a new release every year. PostgreSQL supports the most advanced features included in SQL standards. It also provides NoSQL capabilities and very rich data types and extensions. All of this makes PostgreSQL a very attractive solution in software systems. If you run a database, you want it to perform well and you want to be able to secure it. As the world’s most advanced open source database, PostgreSQL has unique built-in ways to achieve these goals. This book will show you a multitude of ways to enhance your database’s performance and give you insights into measuring and optimizing a PostgreSQL database to achieve better performance. This book is your one-stop guide to elevate your PostgreSQL knowledge to the next level. First, you’ll get familiarized with essential developer/administrator concepts such as load balancing, connection pooling, and distributing connections to multiple nodes. Next, you will explore memory optimization techniques before exploring the security controls offered by PostgreSQL. Then, you will move on to the essential database/server monitoring and replication strategies with PostgreSQL. Finally, you will learn about query processing algorithms.
Table of Contents (19 chapters)
PostgreSQL High Performance Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface

Tracking CPU consuming processes


In this recipe, we are going to use the top command to find the processes that are using a lot of CPU resources.

Getting ready

The top command is a Linux-based utility and it does not work in Unix-based systems. If you are using Solaris then use the prstat command instead to find CPU intensive processes.

How to do it...

The usage of the top command is shown in the following snippet:

bash-3.2$top 
 
Cpu states: 0.0% idle, 82.0% user, 18.7% kernel, 0.8% wait, 0.5% swap 
Memory: 795M real, 12M free, 318M swap, 1586M free swap 
PID USERNAME PRI NICE SIZE RES STATE TIME WCPU CPU COMMAND 
23624 postgres -25 2 208M 4980K cpu 1:20 22.47% 94.43% postgres 
15811 root -15 4 2372K 716K sleep 22:19 0.61% 3.81% java 
20435 admin 33 0 207M 2340K sleep 2:47 0.23% 1.14% postgres 
20440 admin 33 0 93M 2300K sleep 2:28 0.23% 1.14% postgres 
23698 root 33 0 2052K 1584K cpu 0:00 0.23% 0.95% top 
23621 admin 27 2 5080K 3420K sleep...