SlideShare ist ein Scribd-Unternehmen logo
1 von 16
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 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

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Postgresql tutorial
Postgresql tutorialPostgresql tutorial
Postgresql tutorial
 
Postgresql database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1
 
PostgreSQL HA
PostgreSQL   HAPostgreSQL   HA
PostgreSQL HA
 
High Availability PostgreSQL with Zalando Patroni
High Availability PostgreSQL with Zalando PatroniHigh Availability PostgreSQL with Zalando Patroni
High Availability PostgreSQL with Zalando Patroni
 
Top 10 Mistakes When Migrating From Oracle to PostgreSQL
Top 10 Mistakes When Migrating From Oracle to PostgreSQLTop 10 Mistakes When Migrating From Oracle to PostgreSQL
Top 10 Mistakes When Migrating From Oracle to PostgreSQL
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL Administration
 
Looking ahead at PostgreSQL 15
Looking ahead at PostgreSQL 15Looking ahead at PostgreSQL 15
Looking ahead at PostgreSQL 15
 
OpenGurukul : Database : PostgreSQL
OpenGurukul : Database : PostgreSQLOpenGurukul : Database : PostgreSQL
OpenGurukul : Database : PostgreSQL
 
What is new in PostgreSQL 14?
What is new in PostgreSQL 14?What is new in PostgreSQL 14?
What is new in PostgreSQL 14?
 
Linux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performanceLinux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performance
 
[Pgday.Seoul 2017] 6. GIN vs GiST 인덱스 이야기 - 박진우
[Pgday.Seoul 2017] 6. GIN vs GiST 인덱스 이야기 - 박진우[Pgday.Seoul 2017] 6. GIN vs GiST 인덱스 이야기 - 박진우
[Pgday.Seoul 2017] 6. GIN vs GiST 인덱스 이야기 - 박진우
 
[Pgday.Seoul 2020] SQL Tuning
[Pgday.Seoul 2020] SQL Tuning[Pgday.Seoul 2020] SQL Tuning
[Pgday.Seoul 2020] SQL Tuning
 
PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs
 
PostgreSQL Materialized Views with Active Record
PostgreSQL Materialized Views with Active RecordPostgreSQL Materialized Views with Active Record
PostgreSQL Materialized Views with Active Record
 
Backup and-recovery2
Backup and-recovery2Backup and-recovery2
Backup and-recovery2
 
Auditing and Monitoring PostgreSQL/EPAS
Auditing and Monitoring PostgreSQL/EPASAuditing and Monitoring PostgreSQL/EPAS
Auditing and Monitoring PostgreSQL/EPAS
 
PostgreSQL Replication High Availability Methods
PostgreSQL Replication High Availability MethodsPostgreSQL Replication High Availability Methods
PostgreSQL Replication High Availability Methods
 
The PostgreSQL Query Planner
The PostgreSQL Query PlannerThe PostgreSQL Query Planner
The PostgreSQL Query Planner
 
PostgreSQL Deep Internal
PostgreSQL Deep InternalPostgreSQL Deep Internal
PostgreSQL Deep Internal
 
5 Steps to PostgreSQL Performance
5 Steps to PostgreSQL Performance5 Steps to PostgreSQL Performance
5 Steps to PostgreSQL Performance
 

Ähnlich wie PostgreSQL- An Introduction

CS 542 Parallel DBs, NoSQL, MapReduce
CS 542 Parallel DBs, NoSQL, MapReduceCS 542 Parallel DBs, NoSQL, MapReduce
CS 542 Parallel DBs, NoSQL, MapReduce
J Singh
 
Quick guide to PostgreSQL Performance Tuning
Quick guide to PostgreSQL Performance TuningQuick guide to PostgreSQL Performance Tuning
Quick guide to PostgreSQL Performance Tuning
Ron Morgan
 
Building scalable application with sql server
Building scalable application with sql serverBuilding scalable application with sql server
Building scalable application with sql server
Chris Adkin
 

Ähnlich wie PostgreSQL- An Introduction (20)

Intro sql/plsql
Intro sql/plsqlIntro sql/plsql
Intro sql/plsql
 
PostgreSQL Terminology
PostgreSQL TerminologyPostgreSQL Terminology
PostgreSQL Terminology
 
Introduction to mongodb
Introduction to mongodbIntroduction to mongodb
Introduction to mongodb
 
Big data technology unit 3
Big data technology unit 3Big data technology unit 3
Big data technology unit 3
 
PostgreSQL - Case Study
PostgreSQL - Case StudyPostgreSQL - Case Study
PostgreSQL - Case Study
 
(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices
(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices
(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices
 
CS 542 Parallel DBs, NoSQL, MapReduce
CS 542 Parallel DBs, NoSQL, MapReduceCS 542 Parallel DBs, NoSQL, MapReduce
CS 542 Parallel DBs, NoSQL, MapReduce
 
Quick guide to PostgreSQL Performance Tuning
Quick guide to PostgreSQL Performance TuningQuick guide to PostgreSQL Performance Tuning
Quick guide to PostgreSQL Performance Tuning
 
Summary python coding
Summary python codingSummary python coding
Summary python coding
 
Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014
 
Building scalable application with sql server
Building scalable application with sql serverBuilding scalable application with sql server
Building scalable application with sql server
 
Database programming
Database programmingDatabase programming
Database programming
 
Sql server
Sql serverSql server
Sql server
 
Sql server-dba
Sql server-dbaSql server-dba
Sql server-dba
 
Implementing the Database Server session 01
Implementing the Database Server  session 01Implementing the Database Server  session 01
Implementing the Database Server session 01
 
AWS RDS Migration Tool
AWS RDS Migration Tool AWS RDS Migration Tool
AWS RDS Migration Tool
 
PostgreSQL as an Alternative to MSSQL
PostgreSQL as an Alternative to MSSQLPostgreSQL as an Alternative to MSSQL
PostgreSQL as an Alternative to MSSQL
 
SQL Server vs Postgres
SQL Server vs PostgresSQL Server vs Postgres
SQL Server vs Postgres
 
PostgreSQL - Object Relational Database
PostgreSQL - Object Relational DatabasePostgreSQL - Object Relational Database
PostgreSQL - Object Relational Database
 
Presto
PrestoPresto
Presto
 

Mehr von Smita Prasad (6)

Intro to React.js
Intro to React.jsIntro to React.js
Intro to React.js
 
Maven advanced
Maven advancedMaven advanced
Maven advanced
 
Spring @Transactional Explained
Spring @Transactional ExplainedSpring @Transactional Explained
Spring @Transactional Explained
 
Learn Apache Shiro
Learn Apache ShiroLearn Apache Shiro
Learn Apache Shiro
 
Clean code
Clean codeClean code
Clean code
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
 

Kürzlich hochgeladen

%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 

Kürzlich hochgeladen (20)

Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 

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
  • 12.
  • 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