Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Troubleshooting PostgreSQL
Troubleshooting PostgreSQL

Troubleshooting PostgreSQL: Intercept problems and challenges typically faced by PostgreSQL database administrators with the best troubleshooting techniques

Arrow left icon
Profile Icon Hans-Jürgen Schönig
Arrow right icon
€8.99 €19.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2 (5 Ratings)
eBook Mar 2015 164 pages 1st Edition
eBook
€8.99 €19.99
Paperback
€24.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Hans-Jürgen Schönig
Arrow right icon
€8.99 €19.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2 (5 Ratings)
eBook Mar 2015 164 pages 1st Edition
eBook
€8.99 €19.99
Paperback
€24.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€8.99 €19.99
Paperback
€24.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Troubleshooting PostgreSQL

Chapter 2. Creating Data Structures

This chapter is dedicated to data structures and their creation. The following topics will be covered:

  • Grouping columns the right way
  • Deciding on the right data type

Grouping columns the right way

Some people might wonder what is meant by the title of this section. Does it make a difference which order columns are aligned in? This might be a bit surprising, but it does. Even if a table contains the same data, its size on the disk might vary depending on the order of columns. Here is an example:

test=# CREATE TABLE t_test (  i1 int,
          i2 int,
          i3 int,
          v1 varchar(100),
          v2 varchar(100),
          v3 varchar(100)
);
CREATE TABLE
test=# INSERT INTO t_test SELECT 10, 20, 30,
  'abcd', 'abcd', 'abcd'
  FROM generate_series(1, 10000000);
INSERT 0 10000000

A table with three columns has been created. First of all, there are three integer columns. Then some varchar columns are added. In the second statement, 10 million rows are added. The generate_series command is a nice way to generate a list of numbers. In this example, the output of generate_series is not used. I am just utilizing the function...

Deciding on data types and structure

After this brief introduction to organizing columns, it makes sense to discuss various other issues, such as choosing the right data type and normalization. Normalization is a standard technique to organize data and it has proven to be essential over the years. The idea is to avoid redundancy to ensure that changes only have to be made in one place. To make your database project a success, deciding on proper types is essential and will help to prevent a great deal of trouble later on in the project. The goal of this chapter is to make you aware of the potentials of using the right types.

Finding the right type

Finding the right data type sounds easy. However, there is a lot to consider, and there are some issues that might actually cause problems.

varchar versus text

The first two types to be compared are varchar and text. Have you ever seen a data structure like this?

test=# CREATE TABLE t_product (
  prodnr     int,
  name       varchar(20),
  description...

Deciding on normalization

When starting with databases, one of the first things people learn is data normalization. Normalization makes a lot of sense because it helps to reduce redundancy and it ensures that data is structured in a professional and nice way.

However, in some cases, normalization is taken way too far.

The 7th normal form

As mentioned in many cases, normalization can be easily exaggerated. In such a case, performance will suffer and things will be really complex. Here is an example of normalization taken too far: a few years ago, a professor at a local university confronted me with an interesting example when I was talking to students. He told me that he uses the following example to explain to students that normalization can easily be taken too far. He invented the 7th normal form (which, of course, does not exist in professional database literature).

Here is an example:

test=# CREATE TABLE t_test (name text);
CREATE TABLE
test=# INSERT INTO t_test VALUES ('sealevel&apos...

Summary

In this chapter, you learned how to optimize data structures by avoiding some basic pitfalls. Of course, a discussion of how to write data structures properly can never be exhaustive, and around 10 pages are never enough. However, the idea of this chapter was to introduce some of the lesser-known aspects of these topics that you might be able to use to fix your applications.

The next chapter is all about troubleshooting in the sphere of indexing.

Left arrow icon Right arrow icon

Description

If you are a database administrator looking for solutions to common PostgreSQL problems, this is the book for you. The book is suitable for people with intermediate and professional expertise.

Who is this book for?

If you are a database administrator looking for solutions to common PostgreSQL problems, this is the book for you. The book is suitable for people with intermediate and professional expertise.

What you will learn

  • Detect bottlenecks caused by missing indexes
  • Optimize your data structures for optimal memory footprint
  • Write better, performanceoptimized stored procedures
  • Monitor PostgreSQL in an efficient way and deal with system corruption and filesystem issues
  • Detect replicationrelated problems and make replication more failsafe
  • Fix missing indexes and problems arising out of transaction locking
  • Find slow queries and optimize your system for speed

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Mar 30, 2015
Length: 164 pages
Edition : 1st
Language : English
ISBN-13 : 9781783555321
Category :
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Mar 30, 2015
Length: 164 pages
Edition : 1st
Language : English
ISBN-13 : 9781783555321
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 107.97
Troubleshooting PostgreSQL
€24.99
PostgreSQL Replication, Second Edition
€36.99
Learning PostgreSQL
€45.99
Total 107.97 Stars icon
Banner background image

Table of Contents

11 Chapters
1. Installing PostgreSQL Chevron down icon Chevron up icon
2. Creating Data Structures Chevron down icon Chevron up icon
3. Handling Indexes Chevron down icon Chevron up icon
4. Reading Data Efficiently and Correctly Chevron down icon Chevron up icon
5. Getting Transactions and Locking Right Chevron down icon Chevron up icon
6. Writing Proper Procedures Chevron down icon Chevron up icon
7. PostgreSQL Monitoring Chevron down icon Chevron up icon
8. Fixing Backups and Replication Chevron down icon Chevron up icon
9. Handling Hardware and Software Disasters Chevron down icon Chevron up icon
10. A Standard Approach to Troubleshooting Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2
(5 Ratings)
5 star 60%
4 star 20%
3 star 0%
2 star 20%
1 star 0%
Charles Feduke Aug 20, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Phenomenal book, gets right to the point and reads quickly and conversationally. We had some issues with performance with ingesting large data sets and I was able to read this book in an afternoon and figure out where we needed to go in order to speed things up. There's a ton of just really great info in this book and pretty much no beginner info, other than clarifications where the official documentation might be ambiguous.The only missing thing in the indexing chapter is a discussion about full text indexing (which does a really great job of performing better than the pg_trgm extension suggested in that chapter for our particular use case - wildcard matching with unanchored LIKE predicates).
Amazon Verified review Amazon
Charles C. Jensen May 27, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Excellent guide on troubleshooting PostgreSQL--offers a few good tips not covered as thoroughly in my other PostgreSQL books. Very handy reference with with examples and illustrations.
Amazon Verified review Amazon
Lisa P. Jul 19, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Libro che offre spunti davvero molto interessanti per configurare postgres e strutturare/gestire al meglio i propri database. Utile anche da affiancare alla documentazione ufficiali.
Amazon Verified review Amazon
tony Jul 12, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
I felt like I learned quite a bit by reading this book. As someone who works on an ops team that uses PostgreSQL as part of our stack, there were a few things that I found fairly helpful such as the queries related to finding out how Postgres determines the best method of execution and how the order of a query is executed. The query order outline was very helpful. Additionally, this book highlights some useful functionality that is already contained in PostgreSQL, such as the distance operator for geometric values, that save time by including it as a query instead of having to write a specific function.In terms of its organization, it seems to touch on all of the most common pain points such as indices, normalization (although it doesn't touch too much on the concept except to explain how this can get out of hand), replication, joins, etc. I'll continue to use this book as a reference, especially when going through the PostgreSQL documentation to research a problem finds daunting (although I'm usually able to find what I'm looking for with a simple search).I would note that this book is, like PostgreSQL in general, much more for Linux, a little less for OSX and a lot less for Windows. Some sections, such as modifying the OS parameters (primarily kernels) for optimization require some background knowledge as the different kernel parameters are not explained so much as they are presented as "change your kernel parameter to this". Other concepts, such as checksums, are recommended but not necessarily explained very much (although a Google search or browse on Wikipedia should clear that up if you're not familiar).I don't think this book is so much for someone who's working with PostgreSQL for the very first time, but intermediate users should not have any issues following along and picking up tips to optimize their performance. The explanations on data type comparisons were pretty good as well.
Amazon Verified review Amazon
Luca Ferrari Dec 05, 2017
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
I work with PostgreSQL since version 7.3, I don't claim to be an expert, but I believe I know enough concepts about such system. The book is interesting, but it just points out to possible problems the author had faced during his life. I was expecting something more complex and deeper, like an index checklist or hardware sizing.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.