Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
PostgreSQL Administration Essentials
PostgreSQL Administration Essentials

PostgreSQL Administration Essentials: Discover efficient ways to administer, monitor, replicate, and handle your PostgreSQL databases

eBook
₹799.99 ₹1787.99
Paperback
₹2233.99
Subscription
Free Trial
Renews at ₹800p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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

Shipping Address

Billing Address

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

PostgreSQL Administration Essentials

Chapter 1. Installing PostgreSQL

In this chapter, we will cover the installation process of PostgreSQL. You will learn how to install binary packages and see how PostgreSQL can be compiled from source. Compiling from source is especially important if you happen to be using platforms on which no binaries are available (for example, AIX, HPUX, and so on).

We will cover the following topics in this chapter:

  • Preparing your setup
  • Installing binary packages
  • Compiling PostgreSQL from source
  • Understanding the existing databases
  • Creating databases

You will see how easy it is to make PostgreSQL work in a couple of minutes.

Preparing your setup

Before we dig into the actual installation process and see how things can be put to work, it makes sense to talk a little bit about the PostgreSQL version numbers. Understanding the PostgreSQL versioning policy will give you valuable insights, especially with respect to your upgrade policy, downtime management, and so on.

Understanding the PostgreSQL version numbers

As you might have already seen, a PostgreSQL version number consists of three digits. The logic of the version number is as follows:

  • Minor releases: 9.4.2, 9.4.1, 9.4.1
  • Major releases: 9.4.0, 9.3.0, 9.2.0
  • N.0.0 releases (super major): 9.0.0, 8.0.0, 7.0.0

The distinction between the preceding three types of releases is pretty important. Why is that? Well, if you happen to upgrade to a new minor release (say, from 9.4.1 to 9.4.3), all you have to do is stop the database and start the new binaries. There is no need to touch the data. In short, the amount of downtime needed is basically close to zero.

Note that a minor release only contains bug fixes, improvements in the documentation, and so on. It will never add new features, change the functionality, or remove existing stuff.

Tip

You can safely update to a more recent minor release to improve reliability. The risk involved is negligible.

In case of a major version change, you definitely have to plan things a little better because updates are a bit more complicated (pg_dump / pg_restore or pg_upgrade).

Choosing the right version

When I am training people, they ask me on a regular basis which version of PostgreSQL they should use. The answer to this question is simple; if you have the ability to decide freely, it is absolutely safe to use the latest stable release of PostgreSQL, even if it is a "zero" release (which is equal to 9.4.0, 9.3.0, and so on).

Installing binary packages

After this little introduction to PostgreSQL versioning, we can move forward and see how binary packages can be installed. Nowadays, most people use binary packages that are shipped with their preferred Linux distribution. These packages are tested, easy to use, and readily available.

In this chapter, we will show you how to install PostgreSQL on Debian or Ubuntu and on Red-Hat-based systems.

Installing PostgreSQL on Debian or Ubuntu

Let's focus on installing PostgreSQL on Debian or Ubuntu first. The key point here is that it is recommended to add the PostgreSQL repositories to Ubuntu. The reason is that many Linux distributions, including Ubuntu, ship very old and outdated versions of PostgreSQL in their standard setup. If you don't want to miss a couple of years of PostgreSQL development, adding the current repositories will be highly beneficial to you. The process of adding the repositories is as follows:

  1. Create a file called /etc/apt/sources.list.d/pgdg.list, and add a line for the PostgreSQL repository (the following steps can be done as a root user or by using sudo). Alternatively, /etc/apt/sources.list is a place to put the line:
    deb http://apt.postgresql.org/pub/repos/apt/ YOUR_DEBIAN_VERSION_HERE-pgdg main
    
  2. So, in case of Wheezy, the following line will be useful:
    deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main
    
  3. Once we add the repository, we can import the signing key:
    $# wget --quiet -O - \
      https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
      apt-key add -
    OK
    
  4. Once the key has been added, we can update our package information and install PostgreSQL:
    apt-get update
    
  5. In our case, we will install PostgreSQL 9.4. Of course, you can also decide to use 9.3 or any other recent version you desire:
    apt-get install "postgresql-9.4"
    
  6. All relevant packages will be downloaded automatically, and the system will instantly fire up PostgreSQL.
  7. Once all these steps have been performed, you are ready for action. You can try to connect to the database:
    root@chantal:~# su - postgres
    $ psql postgres
    psql (9.4.1)
    Type "help" for help.
    postgres=#
    

Installing PostgreSQL on Red-Hat-based systems

The installation process on Red Hat-based distributions works in a pretty similar way. Many distributions use RPM packages. The following URL shows the distributions for which we are currently ready to use RPMs: http://yum.postgresql.org/repopackages.php.

The first thing to do is to install an RPM package containing all the repository information. Once this is done, we can easily fetch PostgreSQL RPMs from the repository and fire things up in almost no time.

In our example, we chose Fedora 20 as our distribution. To enable the repository, we can run the following command (as root):

yum install http://yum.postgresql.org/9.4/fedora/fedora-20-x86_64/pgdg-fedora94-9.4-1.noarch.rpm

Once the repository has been added, we can install PostgreSQL by using the following commands:

yum install postgresql94-server postgresql94-contrib
/usr/pgsql-9.4/bin/postgresql94-setup initdb
systemctl enable postgresql-9.4.service
systemctl start postgresql-9.4.service

The first command (yum install) will fetch the packages from the repository and install them on your server. Once this is done, we can prepare a database instance and initialize it.

Finally, we enable the service and start it up. Our database server is now ready for action.

Compiling PostgreSQL from source

So far, you've seen how to install binary packages. However, in some cases, you might want to compile PostgreSQL from source all by yourself. There are several reasons for this:

  • SLAs: You might have to provide an old version, which is not available as package anymore, to fulfill some SLA agreements.
  • No packages available: On your favorite flavor of Linux, there is most likely a package containing PostgreSQL available always. However, what about AIX, Solaris, HPUX, and others?
  • Custom patches: Some people write custom patches to enhance PostgreSQL.
  • Split directories: You might want to split the binary and library directories and make sure that PostgreSQL does not integrate tightly into the existing OS.
  • Configure options: Custom configure options, or some other options, to enable dtrace.

How it works

Before we get started, we have to download the tarball from http://ftp.postgresql.org/pub/source/. There, you will find one directory per version of PostgreSQL. In our case, we have downloaded PostgreSQL 9.4.1, and we will use it throughout this chapter.

The first thing we have to do is to extract the tar archive:

tar xvfz postgresql-9.4.1.tar.gz

This will create a directory containing the PostgreSQL source code. Once we have entered this directory, we can call configure, which will then check your system to see if all libraries you need are present. It generates vital parts of the build infrastructure.

Here is how it works:

./configure --prefix=/usr/local/pg941

In our example, we used the most simplistic of all configurations. We want to install the binaries to a directory called /usr/local/pg941. Note that this is not where the data will end up; it is where the executables will reside. If you don't define –prefix, the default installation path will be /usr/local/pgsql.

Of course, there is a lot more. Try running the following command:

./configure --help

If you run the preceding command, you will see that there are some more features that can be turned on (for example, --with-perl or --with-python) in case you are planning to write stored procedures in Perl or Python.

In some cases, you might find that our operating system lacks libraries needed to compile PostgreSQL properly. Some of the most common candidates are libreadline-dev and zlib-dev (of course there are some more). These two libraries are needed to enable the command-line history as well as to give support for compression. We highly recommend providing both libraries to PostgreSQL.

Tip

Keep in mind that the two previously defined libraries have slightly different names on different Linux distributions because every Linux distribution uses slightly different naming conventions.

If you are compiling on a more exotic Unix operating system such as Solaris, AIX, and so on, we recommend you to check out the documentation regarding the platform specifications.

We can move forward and actually compile PostgreSQL, using the following commands:

make
make install

You just have to call make and make install (as root) and wait for a few seconds. In this case, we simply use one CPU core to build PostgreSQL. If you want to scale out the build process to many CPU cores, you can use –j, shown as follows:

make -j 8

The -j 8 command will tell make to do up to 8 things in parallel, if possible. Adding parallelism to the build process will definitely speed up the process. It is not uncommon to build PostgreSQL in 30 seconds or less if there are enough CPU cores on board.

Installing the contrib packages

It is highly recommended to install the PostgreSQL contrib packages as well. Contrib is a set of additional modules that can be used for different purposes such as creating database links from PostgreSQL, to PostgreSQL, or for adding an additional indexing functionality.

If you are installing PostgreSQL from binary packages, you can simply install one more package (for example, postgresql-9.3-contrib). If you happen to install from source, you have to perform the following steps:

cd contrib
make
make install

Of course, you can also use the -j flag again to scale out to more than just one CPU. The make install command will need root permissions again (for example, via sudo).

Finalizing your installation

Once the binaries have been installed, we can move forward and finalize our installation. The following steps are to be carried out in order to finalize our installation:

  • Creating and configuring a user to run PostgreSQL
  • Creating a database instance
  • Deploying the init scripts

If you have installed PostgreSQL from binary packages, the system will automatically create a user for PostgreSQL. If you happen to compile it yourself, you have to create the operating system user yourself too.

Depending on the operating system you are using, this works in a slightly different way. On Ubuntu, for instance, you can call adduser on Red Hat and useradd on CentOS. I really recommend looking up the procedure to create a user in your operating system manual.

In general, it's best practice to create a user named postgres; however, a nonroot user will also do. I just recommend sticking to the standard to make life easier on the administration front.

Once the user has been created, it is, in general, a good idea to prepare your infrastructure for PostgreSQL. This implies adjusting your $PATH environment variable. On most Linux systems, this can be done in your .bash_profile or .bashrc file. Having your favorite PostgreSQL tools in your path will make life simple and a lot easier.

Finally, we can add the init scripts to the system. In postgresql-9.4.1/contrib/start-scripts, you will find init scripts for Linux, Mac OS X, and FreeBSD. These scripts are a good framework to make your init process work as expected.

Creating a database instance

Once we compile PostgreSQL and prepare ourselves to launch PostgreSQL, we can create a so-called PostgreSQL database instance. What is a database instance? Well, whenever you start PostgreSQL, you are actually firing up a database instance. So, the instance is really a central thing; it is that which contains all the databases, users, tablespaces, and so on.

In PostgreSQL, a database instance always resides in a database directory. In our example, we want to create the instance under /data:

mkdir /data
chown postgres.postgres /data
su - postgres
initdb -D /data -E unicode

First, we created the directory and assigned it to the postgres user. Then, we created the database instance. The important part here is that we explicitly stated (-E unicode) that we want UTF-8 to be the default character set in our system. If we don't explicitly tell the system what to use, it will check out the locale settings and use the Unix locale as the default for the instance. This might not be the desired configuration for your setup, so it is better to explicitly define the character set.

Also, instead of using -D here, we can set $PGDATA to tell PostgreSQL where the desired place for the database instance is going to be. There's also an initdb --help command that will reveal a handful of additional configuration options.

At this point, we won't go into all the configuration options as it is out of the scope of this book. However, we will point out some really useful flags, described as follows:

  • -A: This defines the default authentication method of local connections. Many people use trust, md5, or peer for this option.
  • -E and --locale: This defines your desired character set and locale settings.
  • -k: This setting will require PostgreSQL to create data page checksums. It is highly recommended to use this setting for mission critical data. The overhead of the page checksums is virtually zero, so you will get a lot more protection for your data at virtually no cost.

Once we create our database instance, we can start our database server.

Firing up PostgreSQL

Firing up PostgreSQL is easy. If we used binary packages, we can use the /etc/init.d/postgresql start or service postgresql start command (as root or by using sudo).

Note that on some Linux distros, it might be necessary to add a version number to the service (for example, /etc/init.d/postgresql-9.4 start). On non-Linux systems, you have to check out your corresponding init routines.

In case you have not installed the start scripts, you can fire up PostgreSQL manually. Assuming that our database instance resides in /data, it works like this:

pg_ctl -D /data -l /dev/null start

In the preceding command, pg_ctl is the tool to control PostgreSQL, -D tells the system where to find the database instance, -l /dev/null tells our database server to send the log information to /dev/null, and start will simply make the instance fire up.

Note that we use -l here for simplicity reasons. In later chapters, you will learn how to set up proper logging using the PostgreSQL onboard infrastructure.

Installing PostgreSQL is as simple as that.

Understanding the existing databases

Once the database has been launched, we can connect to PostgreSQL using a psql frontend:

psql postgres

Ideally, you connect to a database called postgres, which can be found in any database instance. Some systems don't encourage people to log in as a postgres user. Therefore, you might want to use sudo here as well to log in to PostgreSQL. If this works for you, you can make PostgreSQL display a list of existing databases, where \l will do the job:

postgres=# \x
Expanded display is on.
postgres=# \l
List of databases
-[ RECORD 1 ]-----+----------------------
Name              | postgres
Owner             | postgres
Encoding          | UTF8
Collate           | en_US.UTF-8
Ctype             | en_US.UTF-8
Access privileges |
-[ RECORD 2 ]-----+----------------------
Name              | template0
Owner             | postgres
Encoding          | UTF8
Collate           | en_US.UTF-8
Ctype             | en_US.UTF-8
Access privileges | =c/postgres
                  | postgres=CTc/postgres
-[ RECORD 3 ]-----+----------------------
Name              | template1
Owner             | postgres
Encoding          | UTF8
Collate           | en_US.UTF-8
Ctype             | en_US.UTF-8
Access privileges | =c/postgres
                  | postgres=CTc/postgres

Congratulations, you've completed your first task using the psql shell. If you executed \l as proposed, you might have seen that the table is too wide to be displayed properly. To avoid this, you can use \x to transpose the output and display each column as a separate line. This little feature can come in handy whenever you have to read a wide table.

Tip

If you want to customize the psql shell for your needs, you might want to consider writing a .psqlrc file. It can automatically set things such as \x for you on every login.

In an empty database instance, you will already find the three existing databases template0, template1, and postgres. The rule for you as an end user is simple: always connect to the postgres database and try to avoid connections to the template databases (template0 does not allow connections anyway); these databases are only here to act as a role model in case you create a new database. Make sure that no useless objects are in template0 or template1 because whenever you create an additional database, these useless objects are cloned.

Creating databases

The next logical step is to create a new database. For this operation, PostgreSQL provides an instruction called CREATE DATABASE. Here is the syntax of this vital command:

postgres=# \h CREATE DATABASE
Command:     CREATE DATABASE
Description: create a new database
Syntax:
CREATE DATABASE name
    [ [ WITH ] [ OWNER [=] user_name ]
           [ TEMPLATE [=] template ]
           [ ENCODING [=] encoding ]
           [ LC_COLLATE [=] lc_collate ]
           [ LC_CTYPE [=] lc_ctype ]
           [ TABLESPACE [=] tablespace_name ]
           [ CONNECTION LIMIT [=] connlimit ] ]

The \h command is very convenient to use; it provides you with the syntax of basically every command in the system. In short, \h makes life really easy.

In our case, we can see which options CREATE DATABASE provides. First, we can define the name of the newly created database. The TEMPLATE parameter can be used to physically clone an existing database (if you don't use this one, template1 will be cloned by default). The ENCODING and LC_* parameters are needed in case you want to use encodings and locales different from the default one. Finally, we can make use of a tablespace (which will be dealt with later on in this book), and PostgreSQL provides a way to limit the number of concurrent connections to the database.

In our example, we create a simple database:

postgres=# CREATE DATABASE test;
CREATE DATABASE

If this succeeds, we are ready to connect to our newly created database. We can even do so without psql:

postgres=# \c test
psql (9.4.1, server 9.4.1)
You are now connected to database "test" as user "postgres".

Summary

In this chapter, you learned how to install PostgreSQL binary packages and compile PostgreSQL from source. You also learned how to create database instances and create simple databases inside your instance.

The next chapter will be dedicated to some of the biggest problems in the database world. You will be guided through indexing and detecting performance bottlenecks.

Left arrow icon Right arrow icon

Description

If you are a database administrator who needs to get to grips with PostgreSQL quickly and efficiently, then this book is for you. This book will also be highly beneficial if you are a project leader or a developer who is interested in knowing more about database systems or bottleneck detection, as it will enable you to work more closely and cooperatively with your administrators.

What you will learn

  • Perform routine backups and restore your databases safely
  • Set up replication quickly and easily
  • Handle logfiles and extract information from PostgreSQL
  • Monitor PostgreSQL and integrate it into the existing infrastructure
  • Build desktop applications using C#
  • Optimize PostgreSQL for high speed and tune your database parameters
  • Adjust your user permissions and lock out intruders
  • Detect bottlenecks and find missing indexes with ease
Estimated delivery fee Deliver to India

Premium delivery 5 - 8 business days

₹630.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Oct 10, 2014
Length: 142 pages
Edition : 1st
Language : English
ISBN-13 : 9781783988983
Vendor :
PostgreSQL Global Development Group
Category :
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to India

Premium delivery 5 - 8 business days

₹630.95
(Includes tracking information)

Product Details

Publication date : Oct 10, 2014
Length: 142 pages
Edition : 1st
Language : English
ISBN-13 : 9781783988983
Vendor :
PostgreSQL Global Development Group
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
₹800 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
₹4500 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 ₹400 each
Feature tick icon Exclusive print discounts
₹5000 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 ₹400 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 9,980.97
PostgreSQL Administration Essentials
₹2233.99
PostgreSQL 9 High Availability Cookbook
₹3649.99
PostgreSQL for Data Architects
₹4096.99
Total 9,980.97 Stars icon

Table of Contents

8 Chapters
1. Installing PostgreSQL Chevron down icon Chevron up icon
2. Indexing and Performance Tuning Chevron down icon Chevron up icon
3. Users and Permissions Chevron down icon Chevron up icon
4. Managing Logfiles Chevron down icon Chevron up icon
5. Backup and Recovery Chevron down icon Chevron up icon
6. Handling Replication and Improving Performance Chevron down icon Chevron up icon
7. Monitoring PostgreSQL Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.1
(8 Ratings)
5 star 37.5%
4 star 12.5%
3 star 0%
2 star 25%
1 star 25%
Filter icon Filter
Top Reviews

Filter reviews by




Sally Jan 29, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
easy read, good introduction for someone already familiar with rdbms products.
Amazon Verified review Amazon
Amazon Customer Jul 27, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
very good
Amazon Verified review Amazon
Amazon Customer Nov 03, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Tiene excelentes tips para troubleshooting, te lleva de la mano para que puedas mejorar el performance de tu server sin impactar o perjudicar lo que existe actualmente
Amazon Verified review Amazon
Sebastian Broekhoven Mar 05, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Good written.
Amazon Verified review Amazon
Anthony Garratt Jan 17, 2017
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
This book is pretty awful. By 'essential' it appears to mean scant of detail or explanation, rather than a description of important highlights. The author wastes space by asking pointless questions and then failing to explain adequately why the answer is as it is. For example, "How are xlog files organised? If you look into one of these files, you will see that they are basically unreadable. It is impossible to modify the xlog files." The question in, and of itself, is of little value. This is a common theme in the book.The best bit is the section on logging; that's really the only bit I can recommend.It's quite short at around 120 pages. The Packt books are usually pretty good, so get a different one.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela