SlideShare a Scribd company logo
2
Most read
12
Most read
14
Most read
An Introduction to PostgreSQL
Database
Prepared By: Smita Prasad
 Object-relational database management system (ORDBMS)
 Developed at the University of California at Berkeley Computer Science
Department.
 Open-source descendant of the original Berkeley code.
 It supports a large part of the SQL standard and offers many modern
features:
• Complex queries
• Foreign keys
• Triggers
• Views
• Transactional integrity
• Multi-version concurrency control
 Free of charge for any purpose, be it private, commercial, or academic.
Overview
Comparison with other Databases
Features Not
in Others
• User-defined
types,
• Inheritance,
rules,
• Multi-
version
concurrency
control to
reduce lock
contention
Performance
• Faster for
some things,
slower for
others
• Usually +/-
10%
compared to
other
databases
Reliability
• Stable code
that has a
minimum of
bugs
• Release has
at least one
month of
beta testing
Support
• Mailing lists
• Direct access
to
developers,
the user
community,
manuals, and
the source
code
• Commercial
per-incident
support
Price
• Free for all
use, both
proprietary
and open
source
 PostgreSQL uses a client/server model.
 A PostgreSQL session consists of the following cooperating processes
(programs):
• A server process, which manages the database files, accepts connections to the
database from client applications, and performs database actions on behalf of the
clients. The database server program is called postgres.
• The user's client (frontend) application that wants to perform database
operations. Client applications can be very diverse in nature: a client could be a
text-oriented tool, a graphical application, a web server that accesses the
database to display web pages, or a specialized database maintenance tool.
 The client and the server can be on different hosts. In that case they
communicate over a TCP/IP network connection.
 The PostgreSQL server can handle multiple concurrent connections from
clients. To achieve this it starts ("forks") a new process for each connection.
Architecture
 PostgreSQL is a relational database management
system (RDBMS). That means it is a system for
managing data stored in relations.
 Each table is a named collection of rows. Each row of
a given table has the same set of named columns, and
each column is of a specific data type.
 Tables are grouped into databases, and a collection of
databases managed by a single PostgreSQL server
instance constitutes a database cluster.
Concepts
pgAdmin |||
A graphical tool
for managing and
developing your
databases
Psql Console
Query Tool
 Command for Creating a database
• $ createdb mydb
 Command for deleting a database
• $ dropdb mydb
Creating a Database
 Bundles multiple steps into a single, all-or-nothing operation.
 A transaction is said to be atomic
 Once a transaction is completed and acknowledged by the database system, it has indeed
been permanently recorded and won't be lost even if a crash ensues shortly thereafter.
 When multiple transactions are running concurrently, each one should not be able to see
the incomplete changes made by others.
 If, partway through the transaction, we decide we do not want to commit , we can issue the
command ROLLBACK instead of COMMIT, and all our updates so far will be canceled.
 PostgreSQL actually treats every SQL statement as being executed within a transaction
 Savepoints allow you to selectively discard parts of the transaction, while committing the
rest.
 After defining a savepoint with SAVEPOINT, you can if needed roll back to the savepoint
with ROLLBACK TO.
 All the transaction's database changes between defining the savepoint and rolling back to it
are discarded, but changes earlier than the savepoint are kept.
Transactions
Data Types
PostgreSQL- An Introduction
 PostgreSQL can be extended to support new data types
 Creating a new base type requires implementing functions to operate on the type in a low-level language, usually
C.
 A user-defined type must always have input and output functions.
 These functions determine how the type appears in strings (for input by the user and output to the user) and how
the type is organized in memory.
 Make the input and output functions inverses of each other
User-defined Types
 PostgreSQL implements table inheritance
 A table can inherit from zero or more other tables
 A query can reference either all rows of a table or all rows of a table plus all of its descendant tables
 Not all SQL commands are able to work on inheritance hierarchies
Inheritance
 This is done with the EXPLAIN command
 Figuring out why a statement is taking so long to execute is done with
the EXPLAIN command.
 You can run this two ways; if you use EXPLAIN ANALYZE, it will actually
run the statement and let you compare what the planner thought was
going to happen with what actually did.
 Note that if the statement changes data, that will also happen when
you run with EXPLAIN ANALYZE
 If you just use EXPLAIN the statement doesn't do anything to the
database.
 pgadmin includes a visual EXPLAIN tool that helps map out what's
actually happening.
Query Optimizer
Thank You
Ad

Recommended

Postgresql
Postgresql
NexThoughts Technologies
 
PostgreSQL Database Slides
PostgreSQL Database Slides
metsarin
 
PostgreSQL Tutorial For Beginners | Edureka
PostgreSQL Tutorial For Beginners | Edureka
Edureka!
 
Introduction to PostgreSQL
Introduction to PostgreSQL
Joel Brewer
 
Getting started with postgresql
Getting started with postgresql
botsplash.com
 
Get to know PostgreSQL!
Get to know PostgreSQL!
Oddbjørn Steffensen
 
Postgresql database administration volume 1
Postgresql database administration volume 1
Federico Campoli
 
Sql commands
Sql commands
Pooja Dixit
 
Introduction to PostgreSQL
Introduction to PostgreSQL
Jim Mlodgenski
 
Ms sql-server
Ms sql-server
Md.Mojibul Hoque
 
introduction to NOSQL Database
introduction to NOSQL Database
nehabsairam
 
MS-SQL SERVER ARCHITECTURE
MS-SQL SERVER ARCHITECTURE
Douglas Bernardini
 
MongoDB Administration 101
MongoDB Administration 101
MongoDB
 
MongoDB Aggregation Framework
MongoDB Aggregation Framework
Caserta
 
Sql query patterns, optimized
Sql query patterns, optimized
Karwin Software Solutions LLC
 
Sql queries presentation
Sql queries presentation
NITISH KUMAR
 
Basics of MongoDB
Basics of MongoDB
HabileLabs
 
Structured query language(sql)ppt
Structured query language(sql)ppt
Gowarthini
 
introdution to SQL and SQL functions
introdution to SQL and SQL functions
farwa waqar
 
Mongodb basics and architecture
Mongodb basics and architecture
Bishal Khanal
 
Introduction to MongoDB
Introduction to MongoDB
Ravi Teja
 
PostgreSQL Terminology
PostgreSQL Terminology
Showmax Engineering
 
Schemaless Databases
Schemaless Databases
Dan Gunter
 
PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs
PGConf APAC
 
PostgreSQL Deep Internal
PostgreSQL Deep Internal
EXEM
 
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
Edureka!
 
NOSQL- Presentation on NoSQL
NOSQL- Presentation on NoSQL
Ramakant Soni
 
Working with Databases and MySQL
Working with Databases and MySQL
Nicole Ryan
 
Chjkkkkkkkkkkkkkkkkkjjjjjjjjjjjjjjjjjjjjjjjjjj01_The Basics.pptx
Chjkkkkkkkkkkkkkkkkkjjjjjjjjjjjjjjjjjjjjjjjjjj01_The Basics.pptx
MhmdMk10
 
Introduction to query Processing and sql language.pptx
Introduction to query Processing and sql language.pptx
rajeshwarim53
 

More Related Content

What's hot (20)

Introduction to PostgreSQL
Introduction to PostgreSQL
Jim Mlodgenski
 
Ms sql-server
Ms sql-server
Md.Mojibul Hoque
 
introduction to NOSQL Database
introduction to NOSQL Database
nehabsairam
 
MS-SQL SERVER ARCHITECTURE
MS-SQL SERVER ARCHITECTURE
Douglas Bernardini
 
MongoDB Administration 101
MongoDB Administration 101
MongoDB
 
MongoDB Aggregation Framework
MongoDB Aggregation Framework
Caserta
 
Sql query patterns, optimized
Sql query patterns, optimized
Karwin Software Solutions LLC
 
Sql queries presentation
Sql queries presentation
NITISH KUMAR
 
Basics of MongoDB
Basics of MongoDB
HabileLabs
 
Structured query language(sql)ppt
Structured query language(sql)ppt
Gowarthini
 
introdution to SQL and SQL functions
introdution to SQL and SQL functions
farwa waqar
 
Mongodb basics and architecture
Mongodb basics and architecture
Bishal Khanal
 
Introduction to MongoDB
Introduction to MongoDB
Ravi Teja
 
PostgreSQL Terminology
PostgreSQL Terminology
Showmax Engineering
 
Schemaless Databases
Schemaless Databases
Dan Gunter
 
PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs
PGConf APAC
 
PostgreSQL Deep Internal
PostgreSQL Deep Internal
EXEM
 
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
Edureka!
 
NOSQL- Presentation on NoSQL
NOSQL- Presentation on NoSQL
Ramakant Soni
 
Working with Databases and MySQL
Working with Databases and MySQL
Nicole Ryan
 
Introduction to PostgreSQL
Introduction to PostgreSQL
Jim Mlodgenski
 
introduction to NOSQL Database
introduction to NOSQL Database
nehabsairam
 
MongoDB Administration 101
MongoDB Administration 101
MongoDB
 
MongoDB Aggregation Framework
MongoDB Aggregation Framework
Caserta
 
Sql queries presentation
Sql queries presentation
NITISH KUMAR
 
Basics of MongoDB
Basics of MongoDB
HabileLabs
 
Structured query language(sql)ppt
Structured query language(sql)ppt
Gowarthini
 
introdution to SQL and SQL functions
introdution to SQL and SQL functions
farwa waqar
 
Mongodb basics and architecture
Mongodb basics and architecture
Bishal Khanal
 
Introduction to MongoDB
Introduction to MongoDB
Ravi Teja
 
Schemaless Databases
Schemaless Databases
Dan Gunter
 
PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs
PGConf APAC
 
PostgreSQL Deep Internal
PostgreSQL Deep Internal
EXEM
 
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
Edureka!
 
NOSQL- Presentation on NoSQL
NOSQL- Presentation on NoSQL
Ramakant Soni
 
Working with Databases and MySQL
Working with Databases and MySQL
Nicole Ryan
 

Similar to PostgreSQL- An Introduction (20)

Chjkkkkkkkkkkkkkkkkkjjjjjjjjjjjjjjjjjjjjjjjjjj01_The Basics.pptx
Chjkkkkkkkkkkkkkkkkkjjjjjjjjjjjjjjjjjjjjjjjjjj01_The Basics.pptx
MhmdMk10
 
Introduction to query Processing and sql language.pptx
Introduction to query Processing and sql language.pptx
rajeshwarim53
 
Intro sql/plsql
Intro sql/plsql
Pooja Dixit
 
Introduction to mongodb
Introduction to mongodb
Mohammed Ragab
 
Big data technology unit 3
Big data technology unit 3
RojaT4
 
PostgreSQL - Case Study
PostgreSQL - Case Study
S.Shayan Daneshvar
 
CS 542 Parallel DBs, NoSQL, MapReduce
CS 542 Parallel DBs, NoSQL, MapReduce
J Singh
 
Quick guide to PostgreSQL Performance Tuning
Quick guide to PostgreSQL Performance Tuning
Ron Morgan
 
Summary python coding
Summary python coding
Novita Sari
 
Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014
Michael Renner
 
Building scalable application with sql server
Building scalable application with sql server
Chris Adkin
 
Database programming
Database programming
Shree M.L.Kakadiya MCA mahila college, Amreli
 
Sql server
Sql server
Puja Gupta
 
Sql server-dba
Sql server-dba
NaviSoft
 
Implementing the Database Server session 01
Implementing the Database Server session 01
Guillermo Julca
 
AWS RDS Migration Tool
AWS RDS Migration Tool
Blazeclan Technologies Private Limited
 
PostgreSQL as an Alternative to MSSQL
PostgreSQL as an Alternative to MSSQL
Alexei Krasner
 
SQL Server vs Postgres
SQL Server vs Postgres
chandra sekhar pathivada , PMP,ITIL,MCTS
 
PostgreSQL - Object Relational Database
PostgreSQL - Object Relational Database
Mubashar Iqbal
 
Presto
Presto
Knoldus Inc.
 
Chjkkkkkkkkkkkkkkkkkjjjjjjjjjjjjjjjjjjjjjjjjjj01_The Basics.pptx
Chjkkkkkkkkkkkkkkkkkjjjjjjjjjjjjjjjjjjjjjjjjjj01_The Basics.pptx
MhmdMk10
 
Introduction to query Processing and sql language.pptx
Introduction to query Processing and sql language.pptx
rajeshwarim53
 
Introduction to mongodb
Introduction to mongodb
Mohammed Ragab
 
Big data technology unit 3
Big data technology unit 3
RojaT4
 
CS 542 Parallel DBs, NoSQL, MapReduce
CS 542 Parallel DBs, NoSQL, MapReduce
J Singh
 
Quick guide to PostgreSQL Performance Tuning
Quick guide to PostgreSQL Performance Tuning
Ron Morgan
 
Summary python coding
Summary python coding
Novita Sari
 
Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014
Michael Renner
 
Building scalable application with sql server
Building scalable application with sql server
Chris Adkin
 
Sql server-dba
Sql server-dba
NaviSoft
 
Implementing the Database Server session 01
Implementing the Database Server session 01
Guillermo Julca
 
PostgreSQL as an Alternative to MSSQL
PostgreSQL as an Alternative to MSSQL
Alexei Krasner
 
PostgreSQL - Object Relational Database
PostgreSQL - Object Relational Database
Mubashar Iqbal
 
Ad

More from Smita Prasad (6)

Intro to React.js
Intro to React.js
Smita Prasad
 
Maven advanced
Maven advanced
Smita Prasad
 
Spring @Transactional Explained
Spring @Transactional Explained
Smita Prasad
 
Learn Apache Shiro
Learn Apache Shiro
Smita Prasad
 
Clean code
Clean code
Smita Prasad
 
Maven Basics - Explained
Maven Basics - Explained
Smita Prasad
 
Spring @Transactional Explained
Spring @Transactional Explained
Smita Prasad
 
Learn Apache Shiro
Learn Apache Shiro
Smita Prasad
 
Maven Basics - Explained
Maven Basics - Explained
Smita Prasad
 
Ad

Recently uploaded (20)

Best Practice for LLM Serving in the Cloud
Best Practice for LLM Serving in the Cloud
Alluxio, Inc.
 
Why Edge Computing Matters in Mobile Application Tech.pdf
Why Edge Computing Matters in Mobile Application Tech.pdf
IMG Global Infotech
 
Test Case Design Techniques – Practical Examples & Best Practices in Software...
Test Case Design Techniques – Practical Examples & Best Practices in Software...
Muhammad Fahad Bashir
 
Zoho Creator Solution for EI by Elsner Technologies.docx
Zoho Creator Solution for EI by Elsner Technologies.docx
Elsner Technologies Pvt. Ltd.
 
Top Time Tracking Solutions for Accountants
Top Time Tracking Solutions for Accountants
oliviareed320
 
Why Every Growing Business Needs a Staff Augmentation Company IN USA.pdf
Why Every Growing Business Needs a Staff Augmentation Company IN USA.pdf
mary rojas
 
From Data Preparation to Inference: How Alluxio Speeds Up AI
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
 
arctitecture application system design os dsa
arctitecture application system design os dsa
za241967
 
Microsoft-365-Administrator-s-Guide1.pdf
Microsoft-365-Administrator-s-Guide1.pdf
mazharatknl
 
Simplify Task, Team, and Project Management with Orangescrum Work
Simplify Task, Team, and Project Management with Orangescrum Work
Orangescrum
 
NEW-IDM Crack with Internet Download Manager 6.42 Build 27 VERSION
NEW-IDM Crack with Internet Download Manager 6.42 Build 27 VERSION
grete1122g
 
Which Hiring Management Tools Offer the Best ROI?
Which Hiring Management Tools Offer the Best ROI?
HireME
 
HYBRIDIZATION OF ALKANES AND ALKENES ...
HYBRIDIZATION OF ALKANES AND ALKENES ...
karishmaduhijod1
 
Heat Treatment Process Automation in India
Heat Treatment Process Automation in India
Reckers Mechatronics
 
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
dheeodoo
 
Y - Recursion The Hard Way GopherCon EU 2025
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
 
declaration of Variables and constants.pptx
declaration of Variables and constants.pptx
meemee7378
 
How Automation in Claims Handling Streamlined Operations
How Automation in Claims Handling Streamlined Operations
Insurance Tech Services
 
Complete WordPress Programming Guidance Book
Complete WordPress Programming Guidance Book
Shabista Imam
 
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
 
Best Practice for LLM Serving in the Cloud
Best Practice for LLM Serving in the Cloud
Alluxio, Inc.
 
Why Edge Computing Matters in Mobile Application Tech.pdf
Why Edge Computing Matters in Mobile Application Tech.pdf
IMG Global Infotech
 
Test Case Design Techniques – Practical Examples & Best Practices in Software...
Test Case Design Techniques – Practical Examples & Best Practices in Software...
Muhammad Fahad Bashir
 
Zoho Creator Solution for EI by Elsner Technologies.docx
Zoho Creator Solution for EI by Elsner Technologies.docx
Elsner Technologies Pvt. Ltd.
 
Top Time Tracking Solutions for Accountants
Top Time Tracking Solutions for Accountants
oliviareed320
 
Why Every Growing Business Needs a Staff Augmentation Company IN USA.pdf
Why Every Growing Business Needs a Staff Augmentation Company IN USA.pdf
mary rojas
 
From Data Preparation to Inference: How Alluxio Speeds Up AI
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
 
arctitecture application system design os dsa
arctitecture application system design os dsa
za241967
 
Microsoft-365-Administrator-s-Guide1.pdf
Microsoft-365-Administrator-s-Guide1.pdf
mazharatknl
 
Simplify Task, Team, and Project Management with Orangescrum Work
Simplify Task, Team, and Project Management with Orangescrum Work
Orangescrum
 
NEW-IDM Crack with Internet Download Manager 6.42 Build 27 VERSION
NEW-IDM Crack with Internet Download Manager 6.42 Build 27 VERSION
grete1122g
 
Which Hiring Management Tools Offer the Best ROI?
Which Hiring Management Tools Offer the Best ROI?
HireME
 
HYBRIDIZATION OF ALKANES AND ALKENES ...
HYBRIDIZATION OF ALKANES AND ALKENES ...
karishmaduhijod1
 
Heat Treatment Process Automation in India
Heat Treatment Process Automation in India
Reckers Mechatronics
 
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
dheeodoo
 
Y - Recursion The Hard Way GopherCon EU 2025
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
 
declaration of Variables and constants.pptx
declaration of Variables and constants.pptx
meemee7378
 
How Automation in Claims Handling Streamlined Operations
How Automation in Claims Handling Streamlined Operations
Insurance Tech Services
 
Complete WordPress Programming Guidance Book
Complete WordPress Programming Guidance Book
Shabista Imam
 
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
 

PostgreSQL- An Introduction

  • 1. An Introduction to PostgreSQL Database Prepared By: Smita Prasad
  • 2.  Object-relational database management system (ORDBMS)  Developed at the University of California at Berkeley Computer Science Department.  Open-source descendant of the original Berkeley code.  It supports a large part of the SQL standard and offers many modern features: • Complex queries • Foreign keys • Triggers • Views • Transactional integrity • Multi-version concurrency control  Free of charge for any purpose, be it private, commercial, or academic. Overview
  • 3. Comparison with other Databases Features Not in Others • User-defined types, • Inheritance, rules, • Multi- version concurrency control to reduce lock contention Performance • Faster for some things, slower for others • Usually +/- 10% compared to other databases Reliability • Stable code that has a minimum of bugs • Release has at least one month of beta testing Support • Mailing lists • Direct access to developers, the user community, manuals, and the source code • Commercial per-incident support Price • Free for all use, both proprietary and open source
  • 4.  PostgreSQL uses a client/server model.  A PostgreSQL session consists of the following cooperating processes (programs): • A server process, which manages the database files, accepts connections to the database from client applications, and performs database actions on behalf of the clients. The database server program is called postgres. • The user's client (frontend) application that wants to perform database operations. Client applications can be very diverse in nature: a client could be a text-oriented tool, a graphical application, a web server that accesses the database to display web pages, or a specialized database maintenance tool.  The client and the server can be on different hosts. In that case they communicate over a TCP/IP network connection.  The PostgreSQL server can handle multiple concurrent connections from clients. To achieve this it starts ("forks") a new process for each connection. Architecture
  • 5.  PostgreSQL is a relational database management system (RDBMS). That means it is a system for managing data stored in relations.  Each table is a named collection of rows. Each row of a given table has the same set of named columns, and each column is of a specific data type.  Tables are grouped into databases, and a collection of databases managed by a single PostgreSQL server instance constitutes a database cluster. Concepts
  • 6. pgAdmin ||| A graphical tool for managing and developing your databases
  • 9.  Command for Creating a database • $ createdb mydb  Command for deleting a database • $ dropdb mydb Creating a Database
  • 10.  Bundles multiple steps into a single, all-or-nothing operation.  A transaction is said to be atomic  Once a transaction is completed and acknowledged by the database system, it has indeed been permanently recorded and won't be lost even if a crash ensues shortly thereafter.  When multiple transactions are running concurrently, each one should not be able to see the incomplete changes made by others.  If, partway through the transaction, we decide we do not want to commit , we can issue the command ROLLBACK instead of COMMIT, and all our updates so far will be canceled.  PostgreSQL actually treats every SQL statement as being executed within a transaction  Savepoints allow you to selectively discard parts of the transaction, while committing the rest.  After defining a savepoint with SAVEPOINT, you can if needed roll back to the savepoint with ROLLBACK TO.  All the transaction's database changes between defining the savepoint and rolling back to it are discarded, but changes earlier than the savepoint are kept. Transactions
  • 13.  PostgreSQL can be extended to support new data types  Creating a new base type requires implementing functions to operate on the type in a low-level language, usually C.  A user-defined type must always have input and output functions.  These functions determine how the type appears in strings (for input by the user and output to the user) and how the type is organized in memory.  Make the input and output functions inverses of each other User-defined Types
  • 14.  PostgreSQL implements table inheritance  A table can inherit from zero or more other tables  A query can reference either all rows of a table or all rows of a table plus all of its descendant tables  Not all SQL commands are able to work on inheritance hierarchies Inheritance
  • 15.  This is done with the EXPLAIN command  Figuring out why a statement is taking so long to execute is done with the EXPLAIN command.  You can run this two ways; if you use EXPLAIN ANALYZE, it will actually run the statement and let you compare what the planner thought was going to happen with what actually did.  Note that if the statement changes data, that will also happen when you run with EXPLAIN ANALYZE  If you just use EXPLAIN the statement doesn't do anything to the database.  pgadmin includes a visual EXPLAIN tool that helps map out what's actually happening. Query Optimizer