100% found this document useful (2 votes)
39 views

Postgresql For Data Architects Discover How To Design Develop and Maintain Your Database Application Effectively With Postgresql Maymala

application

Uploaded by

swalusgonim
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
39 views

Postgresql For Data Architects Discover How To Design Develop and Maintain Your Database Application Effectively With Postgresql Maymala

application

Uploaded by

swalusgonim
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 62

Download the full version of the textbook now at textbookfull.

com

PostgreSQL for data architects discover how


to design develop and maintain your database
application effectively with PostgreSQL
Maymala
https://textbookfull.com/product/postgresql-for-
data-architects-discover-how-to-design-develop-
and-maintain-your-database-application-
effectively-with-postgresql-maymala/

Explore and download more textbook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Learning PostgreSQL 10 A beginner s guide to building high


performance PostgreSQL database solutions Juba

https://textbookfull.com/product/learning-postgresql-10-a-beginner-s-
guide-to-building-high-performance-postgresql-database-solutions-juba/

textbookfull.com

PostgreSQL 10 Administration Cookbook Over 165 effective


recipes for database management and maintenance in
PostgreSQL 10 4th Edition Simon Riggs
https://textbookfull.com/product/postgresql-10-administration-
cookbook-over-165-effective-recipes-for-database-management-and-
maintenance-in-postgresql-10-4th-edition-simon-riggs/
textbookfull.com

Procedural Programming with PostgreSQL PL/pgSQL: Design


Complex Database-Centric Applications with PL/pgSQL 1st
Edition Baji Shaik
https://textbookfull.com/product/procedural-programming-with-
postgresql-pl-pgsql-design-complex-database-centric-applications-with-
pl-pgsql-1st-edition-baji-shaik/
textbookfull.com

New Technologies for Glutamate Interaction Neurons and


Glia 1st Edition Maria Kukley

https://textbookfull.com/product/new-technologies-for-glutamate-
interaction-neurons-and-glia-1st-edition-maria-kukley/

textbookfull.com
A business framework for international commercialization
of innovative construction products First Edition Ali
Albassami
https://textbookfull.com/product/a-business-framework-for-
international-commercialization-of-innovative-construction-products-
first-edition-ali-albassami/
textbookfull.com

Mapping Social Memory: A Psychotherapeutic Psychosocial


Approach 1st Edition Nigel Williams

https://textbookfull.com/product/mapping-social-memory-a-
psychotherapeutic-psychosocial-approach-1st-edition-nigel-williams/

textbookfull.com

Beautiful Beadwork from Nature Melissa Shippee

https://textbookfull.com/product/beautiful-beadwork-from-nature-
melissa-shippee/

textbookfull.com

Clinical Neuroanatomy Stephen G. Waxman

https://textbookfull.com/product/clinical-neuroanatomy-stephen-g-
waxman/

textbookfull.com

The Handbook of Formal Methods in Human Computer


Interaction Benjamin Weyers

https://textbookfull.com/product/the-handbook-of-formal-methods-in-
human-computer-interaction-benjamin-weyers/

textbookfull.com
Souvenir Nation Relics Keepsakes and Curios from the
Smithsonian s National Museum of American History 1st
Edition William L. Bird Jr.
https://textbookfull.com/product/souvenir-nation-relics-keepsakes-and-
curios-from-the-smithsonian-s-national-museum-of-american-history-1st-
edition-william-l-bird-jr/
textbookfull.com
PostgreSQL for Data Architects

Discover how to design, develop, and maintain your


database application effectively with PostgreSQL

Jayadevan Maymala

BIRMINGHAM - MUMBAI
PostgreSQL for Data Architects

Copyright © 2015 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the author, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.

First published: March 2015

Production reference: 1240315

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham B3 2PB, UK.

ISBN 978-1-78328-860-1

www.packtpub.com

Cover image by Kai Stachowiak ([email protected])


Credits

Author Project Coordinator


Jayadevan Maymala Judie Jose

Reviewers Proofreaders
Pascal Charest Maria Gould
Bahman Movaqar Clyde Jenkins
Ângelo Marcos Rigo Chris Smith
Hans-Jürgen Schönig Jonathan Todd
Stéphane Wirtel
Indexer
Commissioning Editor Hemangini Bari
Anthony Albuquerque
Graphics
Acquisition Editor Sheetal Aute
Sonali Vernekar Abhinash Sahu

Content Development Editors Production Coordinator


Rahul Nair Aparna Bhagat
Sharvari Tawde
Cover Work
Technical Editor Aparna Bhagat
Shashank Desai

Copy Editor
Relin Hedly
About the Author

Jayadevan Maymala is a database developer, designer, and architect. He started


working with the Oracle database in 1999. Over the years, he has worked with DB2,
Sybase, and SQL Server. Of late, he has been working with open source technologies.
His database of choice is PostgreSQL. In his career, he has worked in different
domains spanning supply chain management, finance, and travel. He has spent
an equal amount of time working with databases supporting critical transaction
processing systems as well as data warehouses supporting analytical systems.

When he is not working on open source technologies, he spends time reading and
updating himself on economic and political issues.

I would like to thank my wife, Uma, for putting up with my


marathon writing sessions over weekends. I am also deeply indebted
to the PostgreSQL community, which has individuals who are
always promptly replying to my basic and not-so-basic queries.
It's an amazing team that has been working tirelessly to build such
a great database and then give it away for free with such liberal
licensing terms. Thank you.
About the Reviewers

Pascal Charest is a cutting-edge technology professional working with a very wide


array of open source technologies.

He is currently leading system administrators in strategic planning of networked


infrastructures and is often consulted for system architecture design. He can be
reached via his LinkedIn profile at http://www.linkedin.com/in/pascalcharest.

I'd like to thank Anthony and Zachary for keeping me awake,


day and night.

Bahman Movaqar has been developing, deploying, and delivering software


for the past 14 years, ranging from embedded operating systems to ERP
implementations. He's an open source believer and a passionate amateur
chess player. He blogs at http://bahmanm.com/.

I'd like to thank my lovely wife, Nahid, who has taught me how to
be strong.
Ângelo Marcos Rigo has a strong background in web development since
1998, focusing on content management systems. For the past 7 years, he has been
managing, customizing, and developing extensions for Moodle LMS. He can be
reached at his website http://www.u4w.com.br/novosite/index.php for CMS or
Moodle LMS consulting. He has reviewed Moodle Security, Packt Publishing.

I would like to thank my wife, Janaina de Souza, and my daughter,


Lorena Rigo, for their support when I was away reviewing this book.

Hans-Jürgen Schönig has been involved in professional PostgreSQL training,


consulting, and support for more than 15 years now. He and his company Cybertec
Schönig & Schönig GmbH (http://www.cybertec.at/) are serving clients around
the globe and have worked on some of the world's largest PostgreSQL deployments.

Stéphane Wirtel is an enthusiast software craftsman who is interested in high


availability, replication, and distributed systems. Since 2000, he has been using
PostgreSQL with the Python programming language. Stephane gives talks on Python
and PostgreSQL in several conferences in Europe. The last one was called Python &
PostgreSQL, a Wonderful Wedding. He is also a former core developer of the Odoo
project, having worked on it for 6 years.

Stéphane is also a member of the Python Software Foundation and the


EuroPython Society. He promotes the Python programming language via the
PythonFOSDEM event at Brussels. You can reach him at http://wirtel.be/
or via Twitter @matrixise.

He works for Mgx.IO, a company that specializes in Python and Erlang


developments. You can reach this company at http://mgx.io/ or via Twitter
@mgxio. He has also reviewed the books Getting Started with PhantomJS and
PhantomJS Cookbook, both by Packt Publishing.

I would like to thank my wife, Anne, my daughter, Margaux,


my family and friends for their support, and the PostgreSQL
and Python communities for the awesome tools.
www.PacktPub.com

Support files, eBooks, discount offers, and more


For support files and downloads related to your book, please visit
www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF
and ePub files available? You can upgrade to the eBook version at www.PacktPub.
com and as a print book customer, you are entitled to a discount on the eBook copy.
Get in touch with us at [email protected] for more details.

At www.PacktPub.com, you can also read a collection of free technical articles,


sign up for a range of free newsletters and receive exclusive discounts and offers
on Packt books and eBooks.
TM

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital
book library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print, and bookmark content
• On demand and accessible via a web browser

Free access for Packt account holders


If you have an account with Packt at www.PacktPub.com, you can use this to access
PacktLib today and view 9 entirely free books. Simply use your login credentials for
immediate access.
Table of Contents
Preface vii
Chapter 1: Installing PostgreSQL 1
Installation options 1
Downloading and extracting the source 2
Inspecting the contents 3
Dependencies to compile the source 4
Configuring and creating the makefile 5
Building and creating the executables 8
Installing and moving the files to where they belong 9
Inspecting the changes 10
Initializing a cluster 11
A quick walk through the directories 14
Processes created 17
Important files created 17
Working with extensions 18
Summary 19
Chapter 2: Server Architecture 21
Starting with the daemon process 21
Understanding the shared buffer 23
Inspecting the buffer cache 25
Checkpoint 29
WAL and the WAL writer process 32
Recovery 34
Incremental backup and point-in-time recovery 34
Replication 34
The background writer 36
The autovacuum launcher process 37

[i]
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Table of Contents

The logging process 41


The stats collector process 46
The WAL sender and WAL receiver 49
Sorting in memory with work_mem 49
Maintenance with maintenance_work_mem 51
Understanding effective_cache_size 53
Summary 54
Chapter 3: PostgreSQL – Object Hierarchy and Roles 55
The PostgreSQL cluster 55
Understanding tablespaces 56
Managing temporary objects with temporary tablespaces 59
Views 61
Databases, schemas, and search_path 61
Schemas – use cases 67
Roles and privileges 67
Summary 72
Chapter 4: Working with Transactions 73
Understanding transactions 73
ACID properties of transactions 76
A for atomicity 76
C for consistency 76
I for isolation 76
D for durability 85
PostgreSQL and MVCC 86
Summary 90
Chapter 5: Data Modeling with SQL Power Architect 91
Tools for databases and their uses 91
Database design tools 93
SQL Power Architect – downloading and installing 93
Creating tables 95
Generating SQL 97
Reverse engineering and making changes 100
Exporting the data model 101
Profiling 102
Summary 103
Chapter 6: Client Tools 105
GUI tools and command-line tools 105
pgAdmin – downloading and installation 105
Adding a server 106

[ ii ]
Table of Contents

The pgAdmin main window 108


The Query tool 111
psql – working from the command line 114
psql – connection options 114
The power of \d 115
More meta-commands 117
Setting up the environment 120
History of commands 121
Summary 122
Chapter 7: SQL Tuning 123
Understanding basic facts about databases 123
Fact 1 – databases are more frequently read from than written to 123
Fact 2 – data is always read in blocks or pages, not as
individual records or columns 124
Approaches to reducing the number of blocks read/written 125
Query execution components 125
Planner 126
Access methods 126
Join strategies 127
Finding the execution plan 128
Optimization guidelines and catches 130
Indexing foreign keys 130
Using SELECT * 132
Using ORDER BY 133
Using DISTINCT 134
Using UNION ALL instead of UNION 134
Using functions in the FILTER clause 134
Reducing the number of SQL statements 137
Reducing function executions 138
Not using indexes 140
Partial indexes 142
Optimizing functions 143
Summary 145
Chapter 8: Server Tuning 147
Server-wide memory settings 147
shared_buffers 147
effective_cache_size 148
Managing writes, connections, and maintenance 149

[ iii ]
Table of Contents

Seek/scan cost and statistics parameters 151


CPU costs 155
Materialized views 157
Partitioned tables 160
Summary 165
Chapter 9: Tools to Move Data in and out of PostgreSQL 167
Setting up the production database – considerations 167
COPY 168
Fast loading with pg_bulkload 171
pg_dump 173
Filtering options 175
pg_dumpall 176
pg_restore 176
Summary 178
Chapter 10: Scaling, Replication, and Backup and Recovery 179
Scalability 179
Vertical scaling 181
Horizontal scaling 182
Master-slave(s) with read/write separation 182
Streaming replication 184
Connection pooling, load balancing, and failover with pgpool-II 189
Sharding 199
Multi-master full replication 201
Point-in-time recovery 202
Summary 206
Chapter 11: PostgreSQL – Troubleshooting 207
Connection issues 207
Authentication and permission issues 208
Parameter changes not effective 210
Query not responding 212
Summary 216
Chapter 12: PostgreSQL – Extras 217
Interesting data types 217
RANGE 218
Using network address types 220
hstore for key-value pairs 222
json/jsonb 224
XML 227
Inserting and verifying XML data 228
Generating XML files for table definitions and data 228

[ iv ]
Table of Contents

Geometry and geography 229


Foreign Data Wrappers 229
FDW for files 230
PostgreSQL FDW 231
Data wrappers – other aspects 232
pgbadger 233
Features over time 236
Interesting features in 9.4 236
Keeping the buffer ready 236
Better recoverability 238
Easy-to-change parameters 238
Logical decoding and consumption of changes 239
Summary 240
Index 241

[v]
Preface
PostgreSQL is an incredibly flexible and dependable open source relational database.
Harnessing its power will make your applications more reliable and extensible
without increasing costs. Using PostgreSQL's advanced features will save you work
and increase performance, once you've discovered how to set it up.

PostgreSQL for Data Architects will teach you everything you need to learn in order to
get a scalable and optimized PostgreSQL server up and running.

The book starts with basic concepts (such as installing PostgreSQL from source) and
covers theoretical aspects (such as concurrency and transaction management). After
this, you'll learn how to set up replication, use load balancing to scale horizontally,
and troubleshoot errors.

As you continue through this book, you will see the significant impact of
configuration parameters on performance, scalability, and transaction management.
Finally, you will get acquainted with useful tools available in the PostgreSQL
ecosystem used to analyze PostgreSQL logs, set up load balancing, and recovery.

What this book covers


Chapter 1, Installing PostgreSQL, provides an overview of the process to install
PostgreSQL from source. The chapter covers the prerequisites to compile from
source, and the process to initialize a cluster in Unix/Linux environment. It also
covers the directory structure.

Chapter 2, Server Architecture, covers the important processes started when we start a
PostgreSQL cluster and how they work along with the memory structures to provide
the functionality expected from a database management system.

[ vii ]
Preface

Chapter 3, PostgreSQL – Object Hierarchy and Roles, explains various object types and
objects provided by PostgreSQL. Important concepts such as databases, clusters,
tablespaces, and schemas are covered in this chapter.

Chapter 4, Working with Transactions, covers ACID properties of transactions, isolation


levels, and how PostgreSQL provides them. Multiversion concurrency control is
another topic dealt with in this chapter.

Chapter 5, Data Modeling with SQL Power Architect, talks about how we can model
tables and relationships with SQL Power Architect. Some of the aspects that should
be considered when we choose a design tool are also covered in this chapter.

Chapter 6, Client Tools, covers two clients tools (pgAdmin: a UI tool and psql: a
command-line tool). Browsing database objects, generating queries, and generating
the execution plan for queries using pgAdmin are covered. Setting up the
environment variables for connecting from psql, viewing history of SQL commands
executed, and meta-commands are also covered in this chapter.

Chapter 7, SQL Tuning, explains query optimization techniques. To set the context,
some patterns about database use and theory on how the PostgreSQL optimizer
works are covered.

Chapter 8, Server Tuning, covers PostgreSQL server settings that have significant
impact on query performance. These include memory settings, cost settings,
and so on. Two object types: partitions and materialized views are also
covered in this chapter.

Chapter 9, Tools to Move Data in and out of PostgreSQL, covers common tools/utilities,
such as pg_dump, pg_bulkload, and copy used to move data in and out
of PostgreSQL.

Chapter 10, Scaling, Replication, and Backup and Recovery, covers methods that
are usually used for achievability. A step-by-step method to achieve horizontal
scalability using PostgreSQL's streaming replication and pgpool-II is also presented.
Point-in-time recovery for PostgreSQL is also covered in this chapter.

Chapter 11, PostgreSQL – Troubleshooting, explains a few of the most common


problems developers run into when they start off with PostgreSQL and how
to troubleshoot them. Connection issues, privilege issues, and parameter setting
issues are also covered.

Chapter 12, PostgreSQL – Extras, covers quite a few topics. Some interesting data types
that every data architect should be aware of, a couple of really useful extensions, and
a tool to analyze PostgreSQL log files are covered. It also covers a few interesting
features available in PostgreSQL 9.4.

[ viii ]
Preface

What you need for this book


A computer with access to the Internet is mandatory. It will definitely help if the
computer is running on a Unix/Linux operating system.

Who this book is for


You are expected to have some exposure to databases. Basic familiarity with
database objects such as tables and views is expected. You will find this book really
useful if you have no or a little exposure to PostgreSQL. If you have been working
with PostgreSQL for a few years, you should still find a few useful commands that
you were not aware of or a couple of optimization approaches you have not tried.
You will also gain more insight into how the database works.

Conventions
In this book, you will find a number of text styles that distinguish among different
kinds of information. Here are some examples of these styles and an explanation of
their meaning.

Code words in text, database table names, folder names, filenames, file extensions,
pathnames, dummy URLs, user input, and Twitter handles are shown as follows:
"We will use the following wget command to download the source."

A block of code/SQL at psql prompt as well as the output from the server at psql is
set as follows:
CREATE TABLE emp(id serial, first_name varchar(50));

Commands executed at shell/command prompt, the output, and parameters and


settings are formatted as follows:
[root@MyCentOS ~]# ps f -U postgres
PID TTY STAT TIME COMMAND
1918 tty1 S 0:00 /usr/local/pgsql/bin/postgres

New terms and important words are shown in bold.

[ ix ]
Preface

Warnings or important notes appear in a box like this.

Tips and tricks appear like this.

Reader feedback
Feedback from our readers is always welcome. Let us know what you think about
this book—what you liked or disliked. Reader feedback is important for us as it helps
us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail [email protected], and mention


the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support
Now that you are the proud owner of a Packt book, we have a number of things to
help you to get the most from your purchase.

Downloading the example code


You can download the example code files from your account at http://www.
packtpub.com for all the Packt Publishing books you have purchased. If you
purchased this book elsewhere, you can visit http://www.packtpub.com/support
and register to have the files e-mailed directly to you.

[x]
Preface

Errata
Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you find a mistake in one of our books—maybe a mistake in the text or
the code—we would be grateful if you could report this to us. By doing so, you can
save other readers from frustration and help us improve subsequent versions of this
book. If you find any errata, please report them by visiting http://www.packtpub.
com/submit-errata, selecting your book, clicking on the Errata Submission Form
link, and entering the details of your errata. Once your errata are verified, your
submission will be accepted and the errata will be uploaded to our website or added
to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/


content/support and enter the name of the book in the search field. The required
information will appear under the Errata section.

Piracy
Piracy of copyrighted material on the Internet is an ongoing problem across all
media. At Packt, we take the protection of our copyright and licenses very seriously.
If you come across any illegal copies of our works in any form on the Internet, please
provide us with the location address or website name immediately so that we can
pursue a remedy.

Please contact us at [email protected] with a link to the suspected


pirated material.

We appreciate your help in protecting our authors and our ability to bring you
valuable content.

Questions
If you have a problem with any aspect of this book, you can contact us at
[email protected], and we will do our best to address the problem.

[ xi ]
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Installing PostgreSQL
This chapter gives you an overview of the process to install PostgreSQL from the
source. The system used for installation and providing examples in the following
sections is a 64-bit CentOS (6.4) machine. Other Unix/Linux systems typically have
similar commands. For those using Windows systems, there is a set of utilities
available at http://sourceforge.net/projects/unxutils/, which makes it
possible to execute most of the Unix commands (find, grep, cut, and so on) in the
Windows environment. The steps to be followed to install PostgreSQL on Windows
are very different compared to those for Unix/Linux systems and are not covered in
this chapter.

Installation options
There are many possible ways to install PostgreSQL on a system. For Windows,
downloading the Graphical Installer and using this is the easy way. For Linux systems
such as Red Hat Enterprise Linux or CentOS, we could either use Yellow dog Updater
Modified (yum) or Red Hat Package Manager or RPM Package Manager (rpm)
commands to install PostgreSQL. For Ubuntu, PostgreSQL can be installed using the
apt-get command, which in turn works with Ubuntu's Advanced Packaging Tool
(APT). While these options work, we do not get to see what is happening when we
execute these commands, except, of course, that the database gets installed.

Then there are situations where we might want to build from the source.
Assume that all we have is one production server and one development or staging
server. We are on version 9.3. Version 9.4 is about to be released and there are
quite a few interesting features in 9.4 that we want to try out. If we want to install 9.4
in the test server and use it alongside 9.3, without the installations stepping on each
other's toes, compiling from the source with the --prefix= option and specifying
different installation directories is the right approach. We could also set different
default ports. It's also possible that the new version (source) is ready, but the
package for our Linux distribution is not ready yet.

[1]
Installing PostgreSQL

We might use a flavor of Linux for which an installation package is not available at
all. Installation from source is the way forward in these situations. One advantage
with installing from the source is that we don't have to worry too much about
which package to download, the version of operating system (CentOS 6.3 or 6.4?),
architecture (32 bit or 64 bit), and so on. These are more or less irrelevant. Of course,
we should be using an operating system/architecture that is supported by the
database, but that's about it! We also need to download and install all the tools and
utilities necessary to compile and make the software, in this case, PostgreSQL.

So let's get down to it.

Downloading and extracting the source


The source for PostgreSQL is available at http://www.postgresql.org/ftp/
source/.

We can see a number of versions all the way down to version 1 when it was called
Postgres95 and up to the latest production and beta versions. If you belong to the
group who believe that one shouldn't try software that is not at least a few months
old, so that its teething issues are resolved, you should opt for the last-but-one
version. It's a good idea to opt for the latest stable version. The latest versions have
added quite a few very useful features, such as materialized views and an improved
set of JSON functions and operators.

We will use the following wget command to download the source:


wget http://ftp.postgresql.org/pub/source/v9.3.0/postgresql-
9.3.0.tar.gz

It's a good idea to opt for the latest stable version.

Executing this command will give us a window that looks like this:

[2]
Chapter 1

As we can see, the tarred and gzipped source code comes to about 21 MB. As an
aside, the installation files of Oracle—the big RDBMS out here—weighs over 2.2 GB.

The files can be extracted using the following command:


tar -xvf postgresql-9.3.0.tar.gz

The tar command is used to create or extract TapeARchive files. In the preceding
command, the x option is used to extract, v for verbose is used so that we can see
the list of files and folders getting extracted, and the f option is for, well, passing
the name of the file, which will undergo the extraction process. We might need to
provide the z option, so the command will be tar -xzvf if the preceding code in the
tar command does not work. Some versions of tar are intelligent enough to figure
out whether it is a gzipped file or not and will unzip it automatically. The untarred
unzipped files come to around 115 MB.

Inspecting the contents


Let's inspect the contents:
cd postgresql-9.3.0

find ./ -maxdepth 1 -type d

The find command searches for files meeting specific criteria. Here, we instructed
find to limit itself to scanning just one level of subdirectories using maxdepth 1. We
used the type option along with d to tell find that we need files of type directory, as
shown in the following screenshot:

There are four directories:

• src: This directory has most of the core code, namely, code for the backend
processes, optimizer, storage, client utilities (such as psql) and code to
take care of replication, and so on. It also contains the makefiles for various
distributions. For example, we have the files Makefile.hpux, Makefile.
linux, Makefile.openbsd, and Makefile.sco under src/makefile.

[3]
Installing PostgreSQL

• doc: This directory has the source for documentation written in DocBook,
DocBook being an application of Standard Generalized Markup Language
(SGML). It's possible to generate documentation in an HTML format, PDF
format, and a few other formats.
• contrib: This directory is where many extensions are available. These
are add-on modules that do not form part of the core installation, but can
be installed as needed. For example, those who have to connect to other
PostgreSQL databases can install the Foreign Data Wrapper extension:
postgres_fdw. For those who want to access the contents of a file on the
server from a table, there is the file_fdw extension.
• config: This directory contains a few macros that help you configure and
compile the package.

Now let's move on to the dependencies, configuration options, and the actual
installation itself.

Dependencies to compile the source


To compile and build PostgreSQL from source, we need GNU Make Version 3.8 or
higher. The gmake -v command will tell us whether we have gmake and its version.

A compiler is also necessary. GNU Compiler Collection (GCC) is one such toolset
that is included in almost all the Unix systems. The gcc -v command will provide
you with the version of gcc as well as options with which it was configured on the
system, as shown in the following screenshot:

We can use the following commands to install the necessary packages if


they are missing:
• On Ubuntu: sudo apt-get install build-essential
• On RHEL/CentOS: sudo yum groupinstall 'Development
Tools'

[4]
Random documents with unrelated
content Scribd suggests to you:
master in his rounds from morning till night—informed me that there
was a revolution in Petersburg and that cannon were firing in the
capital.
On the evening of the next day, Count Komarovsky, a high officer
of the police, was at our house, and told us of the band of
revolutionaries in the Cathedral Square, the cavalry charge, and the
death of Milorádovitch.[26]
26. When Nicholas became Emperor in place of his brother Constantine, the
revolt of the Decembrists took place in Petersburg on December 14, 1825.
Five of the conspirators were afterwards hanged, and over a hundred
banished to Siberia.

Then followed the arrests—“They have taken so-and-so”; “They


have caught so-and-so”; “They have arrested so-and-so in the
country.” Parents trembled in fear for their sons; the sky was
covered over with black clouds.
During the reign of Alexander, political persecution was rare: it is
true that he exiled Púshkin for his verses, and Labzin, the secretary
of the Academy of Fine Arts, for proposing that the imperial
coachman should be elected a member;[27] but there was no
systematic persecution. The secret police had not swollen to its later
proportions: it was merely an office, presided over by De Sanglin, a
freethinking old gentleman and a sayer of good things, in the
manner of the French writer, Etienne de Jouy. Under Nicholas, De
Sanglin himself came under police supervision and passed for a
liberal, though he remained precisely what he had always been; but
this fact alone serves to mark the difference between the two reigns.
27. The president had proposed to elect Arakchéyev, on the ground of his
nearness to the Tsar. Labzin then proposed the election of Ilyá Baikov, the
Tsar’s coachman. “He is not only near the Tsar but sits in front of him,” he
said.

The tone of society changed visibly; and the rapid demoralisation


proved too clearly how little the feeling of personal dignity is
developed among the Russian aristocracy. Except the women, no
one dared to show sympathy or to plead earnestly in favour of
relations and friends, whose hands they had grasped yesterday but
who had been arrested before morning dawned. On the contrary,
men became zealots for tyranny, some to gain their own ends, while
others were even worse, because they had nothing to gain by
subservience.
Women alone were not guilty of this shameful denial of their dear
ones. By the Cross none but women were standing; and by the
blood-stained guillotine there were women too—a Lucile Desmoulins,
that Ophelia of the French Revolution, wandering near the fatal axe
and waiting her turn, or a George Sand holding out, even on the
scaffold, the hand of sympathy and friendship to the young fanatic,
Alibaud.[28]
28. Camille Desmoulins was guillotined, with Danton, April 5, 1794; his wife,
Lucile, soon followed him. Alibaud was executed July 11, 1836, for an
attempt on the life of Louis Philippe.

The wives of the exiles were deprived of all civil rights;


abandoning their wealth and position in society, they faced a whole
lifetime of slavery in Eastern Siberia, where the terrible climate was
less formidable than the Siberian police. Sisters, who were not
permitted to accompany their condemned brothers, absented
themselves from Court, and many of them left Russia; almost all of
them retained in their hearts a lively feeling of affection for the
sufferers. But this was not so among the men: fear devoured this
feeling in their hearts, and none of them dared to open their lips
about “the unfortunate.”
As I have touched on this subject, I cannot refrain from giving
some account of one of these heroic women, whose history is known
to very few.
§2
In the ancient family of the Ivashevs a French girl was living as a
governess. The only son of the house wished to marry her. All his
relations were driven wild by the idea; there was a great commotion,
tears, and entreaties. They succeeded in inducing the girl to leave
Petersburg and the young man to delay his intention for a season.
Young Ivashev was one of the most active conspirators, and was
condemned to penal servitude for life. For this was a form of
mésalliance from which his relations did not protect him. As soon as
the terrible news reached the young girl in Paris, she started for
Petersburg, and asked permission to travel to the Government of
Irkutsk, in order to join her future husband. Benkendorf tried to
deter her from this criminal purpose; when he failed, he reported the
case to Nicholas. The Tsar ordered that the position of women who
had remained faithful to their exiled husbands should be explained
to her. “I don’t keep her back,” he added; “but she ought to realise
that if wives, who have accompanied their husbands out of loyalty,
deserve some indulgence, she has no claim whatever to such
treatment, when she intends to marry one whom she knows to be a
criminal.”
In Siberia nothing was known of this permission. When she had
found her way there, the poor girl was forced to wait while a
correspondence went on with Petersburg. She lived in a miserable
settlement peopled with released criminals of all kinds, unable to get
any news of her lover or to inform him of her whereabouts.
By degrees she made acquaintances among her strange
companions. One of these was a highwayman who was now
employed in the prison, and she told him all her story. Next day he
brought her a note from Ivashev; and soon he offered to carry
messages between them. All day he worked in the prison; at
nightfall he got a scrap of writing from Ivashev and started off,
undeterred by weariness or stormy weather, and returned to his
daily work before dawn.
At last permission came for their marriage. A few years later, penal
servitude was commuted to penal settlement, and their condition
was improved to some extent. But their strength was exhausted,
and the wife was the first to sink under the burden of all she had
undergone. She faded away, as a flower from southern climes was
bound to fade in the snows of Siberia. Ivashev could not survive her
long: just a year later he too died. But he had ceased to live before
his death: his letters (which impressed even the inquisitors who read
them) were evidence not only of intense sorrow, but of a distracted
brain; they were full of a gloomy poetry and a crazy piety; after her
death he never really lived, and the process of his death was slow
and solemn.
This history does not end with their deaths. Ivashev’s father, after
his son’s exile, transferred his property to an illegitimate son,
begging him not to forget his unfortunate brother but to do what he
could. The young pair were survived by two children, two nameless
infants, with a future prospect of the roughest labour in Siberia—
without friends, without rights, without parents. Ivashev’s brother
got permission to adopt the children. A few years later he ventured
on another request: he used influence, that their father’s name
might be restored to them, and this also was granted.
§3
I was strongly impressed by stories of the rebels and I their fate,
and by the horror which reigned in Moscow. These events revealed
to me a new world, which became more and more the centre of my
whole inner life; I don’t know how it came to pass; but, though I
understood very dimly what it was all about, I felt that the side that
possessed the cannons and held the upper hand was not my side.
The execution of Pestel[29] and his companions finally awakened me
from the dreams of childhood.
29. One of the Decembrists.

Though political ideas occupied my mind day and night, my


notions on the subject were not very enlightened: indeed they were
so wide of the mark that I believed one of the objects of the
Petersburg insurrection to consist in placing Constantine on the
throne as a constitutional monarch.
It will easily be understood that solitude was a greater burden to
me than ever: I needed someone, in order to impart to him my
thoughts and ideals, to verify them, and to hear them confirmed.
Proud of my own “disaffection,” I was unwilling either to conceal it or
to speak of it to people in general.
My choice fell first on Iván Protopópov, my Russian tutor.
This man was full of that respectable indefinite liberalism, which,
though it often disappears with the first grey hair, marriage, and
professional success, does nevertheless raise a man’s character. He
was touched by what I said, and embraced me on leaving the house.
“Heaven grant,” he said, “that those feelings of your youth may ripen
and grow strong!” His sympathy was a great comfort to me. After
this time he began to bring me manuscript copies, in very small
writing and very much frayed, of Púshkin’s poems—Ode to Freedom,
The Dagger, and of Ryléev’s Thoughts. These I used to copy out in
secret; and now I print them as openly as I please!
As a matter of course, my reading also changed. Politics for me in
future, and, above all, the history of the French Revolution, which I
knew only as described by Mme. Provo. Among the books in our
cellar I unearthed a history of the period, written by a royalist; it was
so unfair that, even at fourteen, I could not believe it. I had chanced
to hear old Bouchot say that he was in Paris during the Revolution;
and I was very anxious to question him. But Bouchot was a surly,
taciturn man, with spectacles over a large nose; he never indulged
in any needless conversation with me: he conjugated French verbs,
dictated examples, scolded me, and then took his departure, leaning
on his thick knotted stick.
The old man did not like me: he thought me a mere idler, because
I prepared my lessons badly; and he often said, “You will come to no
good.” But when he discovered my sympathy with his political views,
he softened down entirely, pardoned my mistakes, and told me
stories of the year ’93, and of his departure from France when
“profligates and cheats” got the upper hand. He never smiled; he
ended our lesson with the same dignity as before, but now he said
indulgently, “I really thought you would come to no good, but your
feelings do you credit, and they will save you.”
§4
To this encouragement and approval from my teachers there was
soon added a still warmer sympathy which had a profound influence
upon me.
In a little town of the Government of Tver lived a granddaughter
of my father’s eldest brother. Her name was Tatyana Kuchin. I had
known her from childhood, but we seldom met: once a year, at
Christmas or Shrovetide, she came to pay a visit to her aunt at
Moscow. But we had become close friends. Though five years my
senior, she was short for her age and looked no older than myself.
My chief reason for getting to like her was that she was the first
person to talk to me in a reasonable way: I mean, she did not
constantly express surprise at my growth; she did not ask what
lessons I did and whether I did them well; whether I intended to
enter the Army, and, if so, what regiment; but she talked to me as
most sensible people talk to one another, though she kept the little
airs of superiority which all girls like to show to boys a little younger
than themselves.
We corresponded, especially after the events of 1824; but letters
mean paper and pen and recall the school-room table with its ink-
stains and decorations carved with a penknife. I wanted to see her
and to discuss our new ideas; and it may be imagined with what
delight I heard that my cousin was to come in February (of 1826)
and to spend several months with us. I scratched a calendar on my
desk and struck off the days as they passed, sometimes abstaining
for a day or two, just to have the satisfaction of striking out more at
one time. In spite of this, the time seemed very long; and when it
came to an end, her visit was postponed more than once; such is
the way of things.
One evening I was sitting in the school-room with Protopópov.
Over each item of instruction he took, as usual, a sip of sour broth;
he was explaining the hexameter metre, ruthlessly hashing, with
voice and hand, each verse of Gnyéditch’s translation of the Iliad
into its separate feet. Suddenly, a sound unlike that of town sledges
came from the snow outside; I heard the faint tinkle of harness-bells
and the sound of voices out-of-doors. I flushed up, lost all interest in
the hashing process and the wrath of Achilles, and rushed headlong
to the front hall. There was my cousin from Tver, wrapped up in furs,
shawls, and comforters, and wearing a hood and white fur boots.
Blushing red with frost and, perhaps, also with joy, she ran into my
arms.
§5
Most people speak of their early youth, its joys and sorrows, with
a slightly condescending smile, as if they wished to say, like the
affected lady in Griboyédov’s play, “How childish!” Children, when a
few years are past, are ashamed of their toys, and this is right
enough: they want to be men and women, they grow so fast and
change so much, as they see by their jackets and the pages of their
lesson-books. But adults might surely realise that childhood and the
two or three years of youth are the fullest part of life, the fairest,
and the most truly our own; and indeed they are possibly the most
important part, because they fix all that follows, though we are not
aware of it.
So long as a man moves modestly forwards, never stopping and
never reflecting, and until he comes to the edge of a precipice or
breaks his neck, he continues to believe that his life lies ahead of
him; and therefore he looks down upon his past and is unable to
appreciate the present. But when experience has laid low the flowers
of spring and chilled the glow of summer—when he discovers that
life is practically over, and all that remains a mere continuance of the
past, then he feels differently towards the brightness and warmth
and beauty of early recollections.
Nature deceives us all with her endless tricks and devices: she
makes us a gift of youth, and then, when we are grown up, asserts
her mastery and snares us in a web of relations, domestic and
public, most of which we are powerless to control; and, though we
impart our personal character to our actions, we do not possess our
souls in the same degree; the lyric element of personality is weaker,
and, with it, our feelings and capacity for enjoyment—all, indeed, is
weaker, except intelligence and will.
§6
My cousin’s life was no bed of roses. She lost her mother in
childhood; her father was a passionate gambler, who, like all men
who have gambling in their blood, was constantly rich and poor by
turns and ended by ruining himself. What was left of his fortune he
devoted to his stud, which now became the object of all his thoughts
and desires. His only son, a good-natured cavalry officer, was taking
the shortest road to ruin: at the age of nineteen, he was a more
desperate gambler than his father.
When the father was fifty, he married, for no obvious reason, an
old maid who was a teacher in the Smolny Convent. She was the
most typical specimen of a Petersburg governess whom I had ever
happened to meet: thin, blonde, and very shortsighted, she looked
the teacher and the moralist all over. By no means stupid, she was
full of an icy enthusiasm in her talk, she abounded in commonplaces
about virtue and devotion, she knew history and geography by
heart, spoke French with repulsive correctness, and concealed a high
opinion of herself under an artificial and Jesuitical humility. These
traits are common to all pedants in petticoats; but she had others
peculiar to the capital or the convent. Thus she raised tearful eyes to
heaven, when speaking of the visit of “the mother of us all” (the
Empress, Márya Fyódorovna[30]); she was in love with Tsar
Alexander, and carried a locket or ring containing a fragment of a
letter from the Empress Elizabeth[31]—“il a repris son sourire de
bienveillance!”
30. The wife of Paul and mother of Alexander I and Nicholas.

31. Elizabeth, daughter of Peter the Great, reigned from 1741 to 1762. Probably
il refers to her father.
It is easy to imagine the harmonious trio that made up this
household: a card-playing father, passionately devoted to horses and
racing and noisy carouses in disreputable company; a daughter
brought up in complete independence and accustomed to do as she
pleased in the house; and a middle-aged blue-stocking suddenly
converted into a bride. As a matter of course, no love was lost
between the stepmother and stepdaughter. In general, real
friendship between a woman of thirty-five and a girl of seventeen is
impossible, unless the former is sufficiently unselfish to renounce all
claim to sex.
The common hostility between stepmothers and step-daughters
does not surprise me in the least: it is natural and even moral. A
new member of the household, who usurps their mother’s place,
provokes repulsion on the part of the children. To them the second
marriage is a second funeral. The child’s love is revealed in this
feeling, and whispers to the orphan, “Your father’s wife is not your
mother.” At one time the Church understood that a second marriage
is inconsistent with the Christian conception of marriage and the
Christian dogma of immortality; but she made constant concessions
to the world, and went too far, till she came up against the logic of
facts—the simple heart of the child who revolts against the absurdity
and refuses the name of mother to his father’s second choice.
The woman too is in an awkward situation when she comes away
from the altar to find a family of children ready-made: she has
nothing to do with them, and has to force feelings which she cannot
possess; she is bound to convince herself and the world, that other
people’s children are just as attractive to her as her own.
Consequently, I don’t blame either the convent-lady or my cousin
for their mutual dislike; but I understand how a young girl
unaccustomed to control was eager to go wherever she could be
free. Her father was now getting old and more submissive to his
learned wife; her brother, the officer, was behaving worse and
worse; in fact, the atmosphere at home was oppressive, and she
finally induced her stepmother to let her go on a visit to us, for some
months or possibly for a year.
§7
The day after her arrival, my cousin turned my usual routine, with
the exception of my lessons, upside down. With a high hand she
fixed hours for us to read together, advised me to stop reading
novels, and recommended Ségur’s General History and The Travels
of Anacharsis.[32] From the ascetic point of view she opposed my
strong inclination to smoke on the sly—cigarettes were then
unknown, and I rolled the tobacco in paper myself: in general, she
liked to preach to me, and I listened meekly to her sermons, if I did
not profit by them. Fortunately, she was not consistent: quite
forgetting her own arrangements, she read with me for amusement
rather than instruction, and often sent out a secret messenger in the
shape of a pantry-boy to buy buckwheat cakes in winter or
gooseberries in summer.
32. Voyage du jeune Anacharsis, by the Abbé Barthélemy, published in 1779.
Ségur was a French historian (1753-1830).

I believe that her influence on me was very good. She brought


into my monastic life an element of warmth, and this may have
served to keep alive the enthusiasms that were beginning to stir in
my mind, when they might easily have been smothered by my
father’s ironical tone. I learned to be attentive, to be nettled by a
single word, to care for a friend, and to feel affection; I learned also
to talk about feelings. In her I found support for my political ideas;
she prophesied a remarkable future and reputation for me, and I,
with a child’s vanity, believed her when she said I would one day be
a Brutus or Fabricius.
To me alone she confided the secret of her love for a cavalry
officer in a black jacket and dolman. It was really a secret; for the
officer, as he rode at the head of his squadron, never suspected the
pure little flame that burnt for him in the breast of this young lady of
eighteen. Whether I envied him, I can’t say; probably I did, a little;
but I was proud of being chosen as her confidant, and I imagined
(under the influence of Werther) that this was a tragic passion, fated
to end in some great catastrophe involving suicide by poison or the
dagger. I even thought at times of calling on the officer and telling
him the whole story.
My cousin brought shuttlecocks with her from home. One of them
had a pin stuck into it, and she always used it in playing; if anyone
else happened to get hold of it, she took it away and said that no
other suited her as well. But the demon of mischief, which was
always whispering its temptations in my ear, tempted me to take out
this pin and stick it into another shuttlecock. The trick was entirely
successful: my cousin always chose the shuttlecock with the pin in it.
After a fortnight I told her what I had done: she changed colour,
burst out crying, and ran to her own room. I was frightened and
distressed; after waiting half an hour I went to find her. Her door
was locked, and I asked her to open it. She refused, saying that she
was not well, and that I was an unkind, heartless boy. Then I wrote
a note in which I begged her to forgive me, and after tea we made it
up: I kissed her hand, and she embraced me and explained the full
importance of the incident. A year before, the officer had dined at
their house and played battledore with her afterwards; and the
marked shuttlecock had been used by him. I felt very remorseful, as
if I had committed a real act of sacrilege.
My cousin stayed with us till October, when her father summoned
her home, promising to let her spend the next summer with us in
the country. We looked forward with horror to the separation; and
soon there came an autumn day when a carriage arrived to fetch
her, and her maid carried down baskets and band-boxes, while our
servants put in provisions of all kinds, to last a week, and crowded
to the steps to say their good-byes. We exchanged a close embrace,
and both shed tears; the carriage drove out into the street, turned
into a side-street close to the very shop where we used to buy the
buckwheat cakes, and disappeared. I took a turn in the court-yard,
but it seemed cold and unfriendly; my own room, where I went
next, seemed empty and cold too. I began to prepare a lesson for
Protopópov, and all the time I was thinking, “Where is the carriage
now? has it passed the gates or not?”
I had one comfort: we should spend next June together in the
country.
§8
I had a passionate love for the country, and our visits there gave
me new life. Forests, fields, and perfect freedom—all this was a
complete change to me, who had grown up wrapped in cotton-wool,
behind stone walls, never daring to leave the house on any pretext
without asking leave, or without the escort of a footman.
From spring onwards, I was always much exercised by one
question—shall we go to the country this year or not? Every year my
father said that he wished to see the leaves open and would make
an early start; but he was never ready before July. One year he put
off so long that we never went at all. He sent orders every winter
that the country-house was to be prepared and heated, but this was
merely a deep device, that the head man and ground-officer, fearing
our speedy arrival, might pay more attention to their duties.
It seemed that we were to go. My father said to my uncle, that he
should enjoy a rest in the country and must see what was doing on
the land; but still weeks went by.
The prospect became brighter by degrees. Food supplies were
sent off—tea and sugar, grain of different kinds and wine; then came
another delay; but at last the head man was ordered to send a
certain number of peasants’ horses on a fixed day. Joy! Joy! we are
to go!
At that time I never thought of the trouble caused to the peasants
by the loss of four or five days at the busiest time of the year. I was
completely happy and made haste to pack up my books and
notebooks. The horses came, and I listened with inward satisfaction
to the sound of their munching and snorting in the court. I took a
lively interest in the bustle of the drivers and the wrangles of the
servants, as they disputed where each should sit and accommodate
his belongings. Lights burnt all night in the servants’ quarters: all
were busy packing, or dragging about boxes and bags, or putting on
special clothes for the journey, though it was not more than eighty
versts. My father’s valet was the most excited of the party: he
realised all the importance of packing, pulled out in fury all that
others had put in, tore his hair with vexation, and was quite
impossible to approach.
On the day itself my father got up no earlier than usual—indeed, it
seemed later—and took just as long over his coffee; it was eleven
o’clock before he gave the order to put to the horses. First came a
coach to hold four, drawn by six of our own horses; this was
followed by three or sometimes four equipages—an open carriage, a
britzka, and either a large waggon or two carts; all these were filled
by the servants and their baggage, in addition to the carts which
had preceded us; and yet there was such a squeeze that no one
could sit in comfort.
§9
We stopped half-way, to dine and feed the horses, at a large
village, whose name of Perkhushkov may be found in Napoleon’s
bulletins. It belonged to a son of the uncle, of whom I spoke in
describing the division of the property. The neglected manor-house
stood near the high road, which had dull flat fields on each side of it;
but to me even this dusty landscape was delightful after the
confinement of a town. The floors of the house were uneven, and
the steps of the staircase shook; our tread sounded loud, and the
walls echoed the noise, as if surprised by visitors. The old furniture,
prized as a rarity by its former owner, was now spending its last days
in banishment here. I wandered, with eager curiosity, from room to
room, upstairs and downstairs, and finally into the kitchen. Our cook
was preparing a hasty meal for us, and looked discontented and
scornful; the bailiff was generally sitting in the kitchen, a grey-haired
man with a lump on his head. When the cook turned to him and
complained of the kitchen-range, the bailiff listened and said from
time to time, “Well, perhaps you’re right”; he looked uneasily at all
the stir in the house and clearly hoped we should soon go away.
Dinner was served on special plates, made of tin or Britannia
metal, and bought for the purpose. Meanwhile the horses were put
to; and the hall was filled with those who wished to pay their
respects—former footmen, spending their last days in pure air but
on short commons, and old women who had been pretty house-
maids thirty years ago, all the creeping and hopping population of
great houses, who, like the real locusts, devour the peasants’ toil by
no fault of their own. They brought with them flaxen-haired children
with bare feet and soiled clothes; the children kept pushing forward,
and the old women kept pulling them back, and both made plenty of
noise. The women caught hold of me when they could and
expressed surprise at my growth in the same terms every year. My
father spoke a few words to them; some tried to kiss his hand, but
he never permitted it; others made their bow; and then we went
away.
By the edge of a wood our bailiff was waiting for us, and he rode
in front of us the last part of the way. A long lime avenue led up to
our house from the vicarage; at the house we were met by the
priest and his wife, the sexton, the servants, and some peasants. An
idiot, called Pronka, was there too, the only self-respecting person;
for he kept on his dirty old hat, stood a little apart and grinned, and
started away whenever any of the newcomers tried to approach him.
§10
I have seen few more charming spots than this estate of
Vasílevskoë. On one side, where the ground slopes, there is a large
village with a church and an old manor-house; on the other side,
where there is a hill and a smaller village, was a new house built by
my father. From our windows there was a view for many miles: the
endless corn-fields spread like lakes, ruffled by the breeze; manor-
houses and villages with white churches were visible here and there;
forests of varying hues made a semicircular frame for the picture;
and the ribbon of the Moscow River shone blue outside it. In the
early morning I used to push up my window as high as it would go,
and look, and listen, and drink in the air.
Yet I had a tenderness for the old manor-house too, perhaps
because it gave me my first taste of the country; I had a passion for
the long shady avenue which led up to it, and the neglected garden.
The house was falling down, and a slender shapely birch-tree was
growing out of a crack in the hall floor. A willow avenue went to the
left, followed by reed-beds and white sand, all the way to the river;
about my twelfth year, I used to play the whole morning on this
sand and among the reeds. An old gardener, bent and decrepit, was
generally sitting in front of the house, boiling fruit or straining mint-
wine; and he used to give me peas and beans to eat on the sly.
There were a number of rooks in the garden; they nested in the
tree-tops and flew round and round, cawing; sometimes, especially
towards evening, they rose up in hundreds at a time, rousing others
by their noise; sometimes a single bird would fly quickly from tree to
tree, amid general silence. When night came on, some distant owl
would cry like a child or burst out laughing; and, though I feared
those wild plaintive noises, yet I went and listened.
The years when we did not stay at Vasílevskoë were few and far
between. On leaving, I always marked my height on the wall near
the balcony, and my first business on arriving was to find out how
much I had grown. But I could measure more than mere bodily
growth by this place: the regular recurrence to the same
surroundings enabled me to detect the development of my mind.
Different books and different objects engaged my attention. In 1823
I was still quite a child and took childish books with me; and even
these I left unread, taking more interest in a hare and a squirrel that
lived in a garret near my room. My father allowed me, once every
evening, to fire off a small cannon, and this was one of my chief
delights. Of course, all the servants bore a hand in this occupation,
and grey-haired men of fifty were no less excited than I was. In
1827 my books were Plutarch and Schiller; early in the morning I
sought the remotest part of the wood, lay down under a tree, and
read aloud, fancying myself in the forests of Bohemia. Yet, all the
same, I paid much attention to a dyke which I and another boy were
making across a small stream, and I ran there ten times a day to
look at it and repair it. In 1829 and the next year, I was writing a
“philosophical” review of Schiller’s Wallenstein, and the cannon was
the only one of my old amusements that still maintained its
attraction.
But I had another pleasure as well as firing off the cannon—the
evenings in the country haunted me like a passion, and I feel them
still to be times of piety and peace and poetry.... One of the last
bright hours of my life also recalls to me an evening in the country. I
was in Italy, and she was with me. The sun was setting, solemn and
bright, in an ocean of fire, and melting into it. Suddenly the rich
crimson gave place to a sombre blue, and smoke-coloured vapour
covered all the sky; for in Italy darkness comes on fast. We mounted
our mules; riding from Frascati to Rome, we had to pass through a
small village; lights were twinkling already here and there, all was
peace, the hoofs of the mules rang out on the stone, a fresh
dampish wind blew from the Apennines. At the end of the village
there was a small Madonna in a niche, with a lamp burning before
her; the village girls, coming home from work with white kerchiefs
over their heads, knelt down and sang a hymn, and some begging
pifferari who were passing by added their voices. I was profoundly
impressed and much moved by the scene. We looked at each other,
and rode slowly on to the inn where our carriage was waiting. When
we got home, I described the evenings I had spent at Vasílevskoë.
What was it I described?
The shepherd cracks his long whip and plays on his birch-bark
pipe. I hear the lowing and bleating of the returning animals, and
the stamping of their feet on the bridge. A barking dog scurries after
a straggling sheep, and the sheep breaks into a kind of wooden-
legged gallop. Then the voices of the girls, singing on their way from
the fields, come nearer and nearer; but the path takes a turn to the
right, and the sound dies away again. House-doors open with
creaking of the hinges, and the children come out to meet their
cows and sheep. Work is over. Children play in the street or by the
river, and their voices come penetrating and clear over the water
through the evening glow. The smell of burning passes from the
corn-kilns through the air; the soaking dew begins to spread like
smoke over the earth, the wind seems to walk audibly over the
trees, the sunset glow sends a last faint light over the world—and
Vyéra Artamónovna finds me under a lime-tree, and scolds me,
though she is not seriously angry.
“What’s the meaning of this? Tea has long been served, and
everyone is there. I have looked and looked for you everywhere till
I’m tired out. I’m too old for all this running. And what do you mean
by lying on the wet grass? You’ll have a cold to-morrow, I feel sure.”
“Never mind, never mind,” I would answer laughing; “I shan’t
have a cold, and I want no tea; but you must steal me some cream,
and mind you skim off the top of the jug!”
“Really, I can’t find it in my heart to be angry with you! But how
dainty you are! I’ve got cream ready for you, without your asking.
Look how red the sky is! That’s a sign of a good harvest.”
And then I made off home, jumping and whistling as I went.
§11
We never went back to Vasílevskoë after 1832, and my father sold
it during my banishment. In 1843 we were staying in the country
within twenty versts of the old home and I could not resist paying it
a visit. We drove along the familiar road, past the pine-wood and the
hill covered with nut bushes, till we came to the ford which had
given me such delight twenty years ago—I remembered the
splashing water, the crunching sound of the pebbles, the coachmen
shouting at the jibbing horses. At last we reached the village and the
priest’s house; there was the bench where the priest used to sit,
wearing his brown cassock—a simple kindly man who was always
chewing something and always in a perspiration; and then the
estate-office where Vassíli Epifánov made out his accounts; never
quite sober, he sat crouching over the paper, holding his pen very
low down and tucking his third finger away behind it. The priest was
dead, and Vassíli Epifánov, not sober yet, was making out accounts
somewhere else. The village head man was in the fields, but we
found his wife at their cottage.
Changes had taken place in the interval. A new manor-house had
been built on the hill, and a new garden laid out round it. Returning
past the church and churchyard, we met a poor deformed object,
creeping, as it seemed, on all-fours. It signed to me, and I went
close to it. It was an old woman, bent, paralysed, and half-crazy;
she used to live on charity and work in the old priest’s garden; she
was now about seventy, and her, of all people, death had spared!
She knew me and shed tears, shaking her head and saying: “How
old you have grown! I only knew you by your walk. And me—but
there’s no use talking about me.”
As we drove home, I saw the head man, the same as in our time,
standing in a field some way off. He did not recognise me at first;
but when we were past, he made out who I was, took off his hat,
and bowed low. A little further on, I turned round, and Grigóri Gorski
—that was the head man’s name—was standing on the same spot
and watching our carriage. That tall bearded figure, bowing in the
harvest field, was a link with the past; but Vasílevskoë had ceased to
be ours.
CHAPTER IV

My Friend Niko and the Sparrow Hills.


§1

S
OME time in the year 1824 I was walking one day with my
father along the Moscow River, on the far side of the Sparrow
Hills; and there we met a French tutor whom we knew. He had
nothing on but his shirt, was obviously in great alarm, and was
calling out, “Help! Help!” Before our friend had time to pull off his
shirt or pull on his trousers, a Cossack ran down from the Sparrow
Hills, hurled himself into the water, and disappeared. In another
moment he reappeared, grasping a miserable little object, whose
head and hands shook like clothes hung out to dry; he placed this
burden on the bank and said, “A shaking will soon bring him round.”
The bystanders collected fifty roubles for the rescuer. The Cossack
made no pretences but said very honestly, “It’s a sin to take money
for a thing like that; for he gave me no trouble, no more than a cat,
to pull him out. But,” he added, “though I don’t ask for money, if I’m
offered it, I may as well take it. I’m a poor man. So thank you
kindly.” Then he tied up the money in his handkerchief and went
back to his horses grazing on the hill.
My father asked the man’s name and wrote next day to tell his
commanding officer of his gallantry; and the Cossack was promoted
to be a corporal. A few months later the Cossack appeared at our
house and brought a companion, a German with a fair curling wig,
pock-marked, and scented. This was the drowning man, who had
come to return thanks on behalf of the Cossack; and he visited us
afterwards from time to time.
Karl Sonnenberg had taught boys German in several families, and
was now employed by a distant relation of my father’s, who had
confided to him the bodily health and German pronunciation of his
son. This boy, Nikolai Ogaryóv, whom Sonnenberg always called
Niko, attracted me. There was something kind, gentle, and
thoughtful about him; he was quite unlike the other boys whom I
was in the way of seeing. Yet our intimacy ripened slowly: he was
silent and thoughtful, I was lively and feared to trouble him by my
liveliness.
Niko had lost his mother in infancy, and his grandmother died
about the time when my cousin Tatyana left us and went home.
Their household was in confusion, and Sonnenberg, who had really
nothing to do, made out that he was terribly busy; so he brought the
boy to our house in the morning and asked if we would keep him for
the whole day. Niko was frightened and sad; I suppose he loved his
grandmother.
After sitting together for some time, I proposed that we should
read Schiller. I was soon astonished by the similarity of our tastes:
he knew by heart much more than I did, and my favourite passages
were those he knew best; we soon shut the book, and each began
to explore the other’s mind for common interests.
He too was familiar with the unprinted poems of Púshkin and
Ryléev;[33] the difference from the empty-headed boys whom I
sometimes met was surprising. His heart beat to the same tune as
mine; he too had cut the painter that bound him to the sullen old
shore of conservatism; our business was to push off with a will; and
we decided, perhaps on that very first day, to act in support of the
Crown Prince Constantine!
33. One of the five Decembrists who were hanged when the revolt was
suppressed.

This was our first long conversation. Sonnenberg was always in


our way, persistent as a fly in autumn and spoiling all our talk by his
presence. He was constantly interfering, criticising without
understanding, putting the collar of Niko’s shirt to rights, or in a
hurry to go home; in short, he was thoroughly objectionable. But,
before a month was over, it was impossible for my friend and me to
pass two days without meeting or writing; I, who was naturally
impulsive, became more and more attached to Niko, and he had a
less demonstrative but deep love for me.
From the very first, our friendship was bound to take a serious
turn. I cannot remember that we thought much of amusement,
especially when we were alone. I don’t mean that we sat still
always; after all, we were boys, and we laughed and played the fool
and teased Sonnenberg and shot with a bow in our court-yard. But
our friendship was not founded on mere idle companionship: we
were united, not only by equality of age and “chemical” affinity, but
by a common religion. Nothing in the world has more power to
purify and elevate that time of life, nothing preserves it better, than
a strong interest in humanity at large. We respected, in ourselves,
our own future; we regarded one another as chosen vessels, with a
fixed task before us.
We often took walks into the country; our favourite haunts were
the Sparrow Hills, and the fields outside the Dragomirovsky Gate.
Accompanied by Sonnenberg, he used to come for me at six or
seven in the morning; and if I was still asleep, he used to throw
sand or pebbles at my window. I woke up joyfully and hastened to
join him.
These morning walks had been started by the activity of
Sonnenberg. My friend had been brought up under a dyádka,[34] in
the manner traditional in noble Russian families, till Sonnenberg
came. The influence of the dyádka waned at once, and the oligarchy
of the servants’ hall had to grin and bear it: they realised that they
were no match for the “accursed German” who was permitted to
dine with the family. Sonnenberg’s reforms were radical: the dyádka
even wept when the German took his young master in person to a
shop to buy ready-made boots. Just like the reforms of Peter the
Great, Sonnenberg’s reforms bore a military character even in
matters of the least warlike nature. It does not follow from this that
Sonnenberg’s narrow shoulders were ever covered by epaulettes,
plain or laced—nature has constructed the German on such a plan,
that, unless he is a philologer or theologian and therefore utterly
indifferent to personal neatness, he is invariably military, whatever
civilian sphere he may adorn. Hence Sonnenberg liked tight clothes,
closely buttoned and belted in at the waist; and hence he was a
strict observer of rules approved by himself. He had made it a rule to
get up at six in the morning; therefore he made his pupil get up one
minute before six or, at latest, one minute after it, and took him out
into the fresh air every morning.
34. See note to p. 55.
§2
The Sparrow Hills, at the foot of which Sonnenberg had been so
nearly drowned, soon became to us a Holy Place.
One day after dinner, my father proposed to take a drive into the
country, and, as Niko was in the house, invited him and Sonnenberg
to join us. These drives were no joke. Though the carriage was
made by Iochim, most famous of coachmakers, it had been used, if
not severely, for fifteen years till it had become old and ugly, and it
weighed more than a siege mortar, so that we took an hour or more
to get outside the city-gates. Our four horses, ill-matched both in
size and colour, underworked and overfed, were covered with sweat
and lather in a quarter of an hour; and the coachman, knowing that
this was forbidden, had to keep them at a walk. However hot it was,
the windows were generally kept shut. To all this you must add the
steady pressure of my father’s eye and Sonnenberg’s perpetual fussy
interference; and yet we boys were glad to endure it all, in order
that we might be together.
We crossed the Moscow River by a ferry at the very place where
the Cossack pulled Sonnenberg out of the water. My father walked
along with gloomy aspect and stooping figure, as always, while
Sonnenberg trotted at his side and tried to amuse him with scandal
and gossip. We two walked on in front till we had got a good lead;
then we ran off to the site of Vitberg’s cathedral[35] on the Sparrow
Hills.
35. See part II, chap. IX.

Panting and flushed, we stood there and wiped our brows. The
sun was setting, the cupolas of Moscow glittered in his rays, the city
at the foot of the hill spread beyond our vision, a fresh breeze
fanned our cheeks. We stood there leaning against each other; then

You might also like