Book Image

Learning Heroku Postgres

By : Patrick Rafael de Oliveira Espake
Book Image

Learning Heroku Postgres

By: Patrick Rafael de Oliveira Espake

Overview of this book

Table of Contents (17 chapters)
Learning Heroku Postgres
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Keyword List
Index

Statistics


By definition, statistics is the science that uses probabilistic theories to explain the frequency of the occurrence of events. The Heroku Postgres provides some extensions for database statistics and tables. In upcoming sections, you will learn about them.

Row locking – pgrowlocks

This extension provides a function called pgrowlocks to display locked rows in a specific table.

First, you must install the extension:

$ heroku pg:psql --app your-app-name
CREATE EXTENSION pgrowlocks;

The pgrowlocks function accepts a parameter that is the table name. For example:

SELECT * FROM pgrowlocks('users');
locked_row| lock_type | locker | multi |   xids    |     pids 
----------+-----------+--------+-------+-----------+---------
(0,1)     | Shared    |     22 | t     | {378,809} | {23457} 
(0,2)     | Exclusive |    345 | f     | {780}     | {12869} 

For details, visit the documentation at http://www.postgresql.org/docs/current/static/pgrowlocks.html.

Tuple statistics – pgstattuple

A tuple is a...