SlideShare a Scribd company logo
PostgreSQL - Object Relational Database
Presenter: Mubashar Iqbal Senior Software Engineer Object Relational Database System
Judging Criteria ??
Fast
Flexible
Powerful
Scalable
Easy Deployment
What’s in your mind ?
PostgreSQL - Object Relational Database
Introduction The world's most advanced open source object-relational database system. The open source Oracle. PostgreSQL has a large distributed developer and user community. Community-owned with many companies involved. Supported operating systems ● Linux ● Unix ● Mac OS X ● Solaris ● Windows Native programming interfaces for: C/C++, Java, .Net, Perl, Python, Ruby, PHP
Development Priorities ● Designed by/for Database Administrators ● Data integrity ● Security ● Reliability ● Standards ● DB Features ● Performance ● Ease-of-use ● Programmer Features
Most Common Uses ● ERP ● Data Warehouse ● Geographic ● OEM applications ● Network tools ● CRM
Prominent users ● Yahoo! for web user behavioral analysis, storing two petabytes and claimed to be the largest data warehouse using a heavily modified version of PostgreSQL ● Sony Online multiplayer online games. ● Reddit social news website. ● Skype VoIP application, central business databases. ● Sun xVM, Sun's virtualization and datacenter automation suite. ● MusicBrainz, open online music encyclopedia. ● MyYearbook social networking site. ● Instagram, a popular mobile photo sharing service ● Disqus, an online discussion and commenting service
Features ● PostgreSQL often described as an open-source version of Oracle. ● BSD/MIT type license ● Reliability is PostgreSQL's top priority. ● Well-engineered, capable of supporting high-transaction and mission-critical applications. ● Comprehensive documentation and manuals available for free online. ● Commercial support is available from independent vendors. ● PostgreSQL is fully ACID compliant. ● PostgreSQL is considered the solemn, full-featured, workhorse for transactional enterprise applications, with strong ACID compliance.
Features (contd..) ● PostgreSQL supports one storage engine. ● SSL encryption ● Online backup ● Point-in-time recovery: Restore to any time in the past. ● Regular expression
Tools ● Psql: Command line front-end ● pgAdmin: GUI front-end ● phpPgadmin: Web based front-end ● MS ODBC ● MS Office + Postgres ● NaviCat: $$ ● DeZign: $$ ● EMS SQL Manager for PostgreSQL: $$
Data Types ● Numeric Types ● Character Types ● Hierarchical Types ● Binary Data Types ● Geometric Types ● Network Address Types ● Text Search Types ● UUID Type ● XML Type ● JSON Type ● Arrays ● Composite Types
Indexes B-tree: B-trees can handle equality and range queries on data that can be sorted into some ordering (<, <=,=,>=,>) Hash: Hash indexes can only handle simple equality comparisons GIN: GIN indexes are inverted indexes which can handle values that contain more than one key, arrays for example, GIN operator classes for one-dimensional arrays (<@,@>,=,&&) GiST: Generalized Search Tree, it is a tree-structured access method and also known as two-dimensional geometric data types (<@,@>,=,&&,>>,<<,&<,>&,~=)
Functions A stored procedure and user-defined function is a set of SQL and procedural statements (declarations, assignments, loops, flow-of-control) that stored on the database server and can be invoked using the SQL interface. CREATE FUNCTION function_name(p1 type, p2 type) RETURNS type AS BEGIN -- logic END; LANGUAGE language_name;
Triggers On DML (Data Manipulation Language) SELECT, INSERT, UPDATE, DELETE CREATE TRIGGER name { BEFORE | AFTER } { event [ OR ... ] } ON table [ FOR [ EACH ] { ROW | STATEMENT } ] EXECUTE PROCEDURE funcname ( arguments )
Cursors ● Used instead of FOR. ● Avoid memory overrun. ● Large data set. DECLARE curs1 refcursor; curs2 CURSOR FOR SELECT * FROM tenk1; OPEN curs1 FOR SELECT * FROM foo WHERE key = mykey; FETCH curs2 INTO foo, bar, baz; CLOSE curs1;
View View consists of a stored query accessible as a virtual table in a relational database or a set of documents in a document-oriented database composed of the result set of a query. Views are a great way to simplify your data model. CREATE VIEW table_information AS SELECT * FROM table WHERE id = 123; Now you can simply query your new table directly: SELECT * FROM table_information;
User-defined objects New types of almost all objects inside the database can be created, including: ● Casts ● Conversions ● Data types ● Domains ● Functions, including aggregate functions and window functions ● Indexes including custom indexes for custom types ● Operators (existing ones can be overloaded) ● Procedural languages
Replication Methods 1. Master/Slave ● Asynchronous ● Synchronous 2. Multi-Master ● Asynchronous ● Synchronous 3. Proxy 4. Standby system
Master/Slave Replication Asynchronous Synchronous High availability High availibility Read performance Better read performance Offline peers Worse write performance async M S M S sync
Multi-Master Replication Asynchronous Synchronous Read performance High availiability Faster access across WANs Read performance Manage offline peers Difficult to get good write performance M M M M async sync
Scaling behaviour
Comparison of scaling behaviour
Hierarchical Database Data is organized into a tree like structure. Representing information using parent/child relationships. Each parent can have many children, but each child has only one parent also known as a 1- to-many relationship. Different ways store data like this are • Enumeration path (ltree) • Adjacency List • Nested Sets
LTree – Label Tree ● Ltree is a PostgreSQL module. ● It is implements a data type ltree for representing labels of data stored in a hierarchical tree-like structure. ● Labels must be less than 256 bytes long. ltree stores a label path. ● A label path is a sequence of zero or more labels separated by dots. ● ltree supports several types of indexes that can speed up the indicated operators. ● Ltree performance is much better when you need to do ad-hoc queries over the tree ● Faster than recursive function that constantly needs to recalculate the branching. ● Some other databases have similar types. SQL Server 2008 has a datatype called HierarchyID which serves the same purpose as ltree but with different syntax.
Example Technique Adjacency Ltree Query WITH RECURSIVE d AS ( SELECT id FROM sponsorship WHERE id = 799 UNION ALL SELECT s.id FROM d JOIN sponsorship s ON s.parent_fk = d.id ) SELECT * FROM d ORDER BY id LIMIT 100; WITH p AS ( SELECT path FROM sponsorship WHERE id=799 ) SELECT s.id FROM sponsorship s, p WHERE s.path <@ p.path ORDER BY s.id LIMIT 100; Total Runtime 1946.48 ms 28.00 ms
More Details 1. Value Expression http://www.postgresql.org/docs/9.2/static/sql-expressions.html 2. String Functions and Operators http://www.postgresql.org/docs/9.2/static/functions-string.html 3. Mathematical Functions and Operators http://www.postgresql.org/docs/9.2/static/functions-math.html 4. MySQL vs PostgreSQL http://get.enterprisedb.com/whitepapers/Postgres_Plus_8.4_vs_MySQL_5.5.pdf 5. Scaling Behaviour http://tweakers.net/reviews/657/1/database-test-dual-intel-xeon-5160-introduction.html
References http://www.postgresql.org/ http://tweakers.net/reviews/657/5/database-test-dual-intel-xeon-5160- comparison-of-scaling-behaviour.html http://www.slideshare.net/petereisentraut/replication-solutions-for-postgresql http://gbif.blogspot.com/2012/06/taxonomic-trees-in-postgresql.html http://www.slideshare.net/vuhung16plus/postgre-sqlintroduction20100506
PostgreSQL - Object Relational Database

More Related Content

What's hot (20)

PDF
Patroni - HA PostgreSQL made easy
Alexander Kukushkin
 
PDF
GoldenGateテクニカルセミナー4「テクニカルコンサルタントが語るOracle GoldenGate現場で使える極意」(2016/5/11)
オラクルエンジニア通信
 
PPTX
Extreme Replication - Performance Tuning Oracle GoldenGate
Bobby Curtis
 
PDF
Oracle Multitenant meets Oracle RAC - IOUG 2014 Version
Markus Michalewicz
 
PPT
NOSQL Database: Apache Cassandra
Folio3 Software
 
PDF
Apache Iceberg Presentation for the St. Louis Big Data IDEA
Adam Doyle
 
PDF
Enable oracle database vault
Osama Mustafa
 
PDF
Postgresql database administration volume 1
Federico Campoli
 
PDF
PostgreSQL HA
haroonm
 
PDF
Oracle Database 21c データ・ドリブン時代をリードする コンバージド・データベースの最新型
オラクルエンジニア通信
 
PDF
Real Application Security (RAS) and Oracle Application Express (APEX)
Dimitri Gielis
 
PDF
Oracle Cloud Infrastructure:2021年5月度サービス・アップデート
オラクルエンジニア通信
 
PDF
Oracle GoldenGate 19c を使用した 簡単データベース移行ガイド_v1.0
オラクルエンジニア通信
 
PDF
Oracle GoldenGate for Big Data 12.2 セットアップガイド
オラクルエンジニア通信
 
PDF
Big Data Processing with Spark and Scala
Edureka!
 
PPTX
Oracle GoldenGate Performance Tuning
Bobby Curtis
 
PDF
Apache Arrow Workshop at VLDB 2019 / BOSS Session
Wes McKinney
 
PDF
Oracle GoldenGate Veridata概要
オラクルエンジニア通信
 
PDF
Iceberg: a fast table format for S3
DataWorks Summit
 
PPTX
ORC File - Optimizing Your Big Data
DataWorks Summit
 
Patroni - HA PostgreSQL made easy
Alexander Kukushkin
 
GoldenGateテクニカルセミナー4「テクニカルコンサルタントが語るOracle GoldenGate現場で使える極意」(2016/5/11)
オラクルエンジニア通信
 
Extreme Replication - Performance Tuning Oracle GoldenGate
Bobby Curtis
 
Oracle Multitenant meets Oracle RAC - IOUG 2014 Version
Markus Michalewicz
 
NOSQL Database: Apache Cassandra
Folio3 Software
 
Apache Iceberg Presentation for the St. Louis Big Data IDEA
Adam Doyle
 
Enable oracle database vault
Osama Mustafa
 
Postgresql database administration volume 1
Federico Campoli
 
PostgreSQL HA
haroonm
 
Oracle Database 21c データ・ドリブン時代をリードする コンバージド・データベースの最新型
オラクルエンジニア通信
 
Real Application Security (RAS) and Oracle Application Express (APEX)
Dimitri Gielis
 
Oracle Cloud Infrastructure:2021年5月度サービス・アップデート
オラクルエンジニア通信
 
Oracle GoldenGate 19c を使用した 簡単データベース移行ガイド_v1.0
オラクルエンジニア通信
 
Oracle GoldenGate for Big Data 12.2 セットアップガイド
オラクルエンジニア通信
 
Big Data Processing with Spark and Scala
Edureka!
 
Oracle GoldenGate Performance Tuning
Bobby Curtis
 
Apache Arrow Workshop at VLDB 2019 / BOSS Session
Wes McKinney
 
Oracle GoldenGate Veridata概要
オラクルエンジニア通信
 
Iceberg: a fast table format for S3
DataWorks Summit
 
ORC File - Optimizing Your Big Data
DataWorks Summit
 

Viewers also liked (13)

PDF
Small Overview of Skype Database Tools
elliando dias
 
PDF
The Object Oriented Database System Manifesto
Beat Signer
 
PPT
Object Relational Database Management System
Amar Myana
 
PPT
A brief introduction to PostgreSQL
Vu Hung Nguyen
 
PPT
Object Oriented Database Management System
Ajay Jha
 
PPTX
Cloud Architecture best practices
Omid Vahdaty
 
PDF
Object-Relational Database Systems(ORDBMSs)
Sahan Walpitagamage
 
PPTX
Ordbms
ramandeep brar
 
PDF
Postgres in Production - Best Practices 2014
EDB
 
PPT
Object Oriented Dbms
maryeem
 
PPT
08. Object Oriented Database in DBMS
koolkampus
 
PPT
Types dbms
Avnish Shaw
 
PDF
Practical Object Oriented Models In Sql
Karwin Software Solutions LLC
 
Small Overview of Skype Database Tools
elliando dias
 
The Object Oriented Database System Manifesto
Beat Signer
 
Object Relational Database Management System
Amar Myana
 
A brief introduction to PostgreSQL
Vu Hung Nguyen
 
Object Oriented Database Management System
Ajay Jha
 
Cloud Architecture best practices
Omid Vahdaty
 
Object-Relational Database Systems(ORDBMSs)
Sahan Walpitagamage
 
Postgres in Production - Best Practices 2014
EDB
 
Object Oriented Dbms
maryeem
 
08. Object Oriented Database in DBMS
koolkampus
 
Types dbms
Avnish Shaw
 
Practical Object Oriented Models In Sql
Karwin Software Solutions LLC
 
Ad

Similar to PostgreSQL - Object Relational Database (20)

KEY
PostgreSQL
Reuven Lerner
 
ODP
Introduction to PostgreSQL
Jim Mlodgenski
 
PDF
PostgreSQL - Case Study
S.Shayan Daneshvar
 
PPTX
PostgreSQL- An Introduction
Smita Prasad
 
PPTX
Postgresql
NexThoughts Technologies
 
PPTX
Chjkkkkkkkkkkkkkkkkkjjjjjjjjjjjjjjjjjjjjjjjjjj01_The Basics.pptx
MhmdMk10
 
PPTX
PostgreSQL - It's kind've a nifty database
Barry Jones
 
PDF
An evening with Postgresql
Joshua Drake
 
PDF
Demystifying PostgreSQL
NOLOH LLC.
 
PDF
Demystifying PostgreSQL (Zendcon 2010)
NOLOH LLC.
 
PDF
PostgreSQL 9.0 & The Future
Aaron Thul
 
PDF
Relational vs. Non-Relational
PostgreSQL Experts, Inc.
 
PPTX
PostgreSQL Terminology
Showmax Engineering
 
PPTX
PostgreSQL as an Alternative to MSSQL
Alexei Krasner
 
PDF
PostgreSQL, your NoSQL database
Reuven Lerner
 
PDF
PostgreSQL Prologue
Md. Golam Hossain
 
PPTX
Modern sql
Elizabeth Smith
 
PDF
JDD 2016 - Tomasz Borek - DB for next project? Why, Postgres, of course
PROIDEA
 
PPTX
Sql analytic queries tips
Vedran Bilopavlović
 
PDF
Open Source SQL Databases
Emanuel Calvo
 
PostgreSQL
Reuven Lerner
 
Introduction to PostgreSQL
Jim Mlodgenski
 
PostgreSQL - Case Study
S.Shayan Daneshvar
 
PostgreSQL- An Introduction
Smita Prasad
 
Chjkkkkkkkkkkkkkkkkkjjjjjjjjjjjjjjjjjjjjjjjjjj01_The Basics.pptx
MhmdMk10
 
PostgreSQL - It's kind've a nifty database
Barry Jones
 
An evening with Postgresql
Joshua Drake
 
Demystifying PostgreSQL
NOLOH LLC.
 
Demystifying PostgreSQL (Zendcon 2010)
NOLOH LLC.
 
PostgreSQL 9.0 & The Future
Aaron Thul
 
Relational vs. Non-Relational
PostgreSQL Experts, Inc.
 
PostgreSQL Terminology
Showmax Engineering
 
PostgreSQL as an Alternative to MSSQL
Alexei Krasner
 
PostgreSQL, your NoSQL database
Reuven Lerner
 
PostgreSQL Prologue
Md. Golam Hossain
 
Modern sql
Elizabeth Smith
 
JDD 2016 - Tomasz Borek - DB for next project? Why, Postgres, of course
PROIDEA
 
Sql analytic queries tips
Vedran Bilopavlović
 
Open Source SQL Databases
Emanuel Calvo
 
Ad

Recently uploaded (20)

PPTX
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PPT
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
PDF
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PPTX
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
PPTX
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
PPTX
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
PDF
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
PDF
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
PPTX
Engineering the Java Web Application (MVC)
abhishekoza1981
 
PPTX
MailsDaddy Outlook OST to PST converter.pptx
abhishekdutt366
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PPTX
MiniTool Power Data Recovery Full Crack Latest 2025
muhammadgurbazkhan
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PDF
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
DOCX
Import Data Form Excel to Tally Services
Tally xperts
 
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
Engineering the Java Web Application (MVC)
abhishekoza1981
 
MailsDaddy Outlook OST to PST converter.pptx
abhishekdutt366
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
MiniTool Power Data Recovery Full Crack Latest 2025
muhammadgurbazkhan
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
Import Data Form Excel to Tally Services
Tally xperts
 

PostgreSQL - Object Relational Database

  • 2. Presenter: Mubashar Iqbal Senior Software Engineer Object Relational Database System
  • 11. Introduction The world's most advanced open source object-relational database system. The open source Oracle. PostgreSQL has a large distributed developer and user community. Community-owned with many companies involved. Supported operating systems ● Linux ● Unix ● Mac OS X ● Solaris ● Windows Native programming interfaces for: C/C++, Java, .Net, Perl, Python, Ruby, PHP
  • 12. Development Priorities ● Designed by/for Database Administrators ● Data integrity ● Security ● Reliability ● Standards ● DB Features ● Performance ● Ease-of-use ● Programmer Features
  • 13. Most Common Uses ● ERP ● Data Warehouse ● Geographic ● OEM applications ● Network tools ● CRM
  • 14. Prominent users ● Yahoo! for web user behavioral analysis, storing two petabytes and claimed to be the largest data warehouse using a heavily modified version of PostgreSQL ● Sony Online multiplayer online games. ● Reddit social news website. ● Skype VoIP application, central business databases. ● Sun xVM, Sun's virtualization and datacenter automation suite. ● MusicBrainz, open online music encyclopedia. ● MyYearbook social networking site. ● Instagram, a popular mobile photo sharing service ● Disqus, an online discussion and commenting service
  • 15. Features ● PostgreSQL often described as an open-source version of Oracle. ● BSD/MIT type license ● Reliability is PostgreSQL's top priority. ● Well-engineered, capable of supporting high-transaction and mission-critical applications. ● Comprehensive documentation and manuals available for free online. ● Commercial support is available from independent vendors. ● PostgreSQL is fully ACID compliant. ● PostgreSQL is considered the solemn, full-featured, workhorse for transactional enterprise applications, with strong ACID compliance.
  • 16. Features (contd..) ● PostgreSQL supports one storage engine. ● SSL encryption ● Online backup ● Point-in-time recovery: Restore to any time in the past. ● Regular expression
  • 17. Tools ● Psql: Command line front-end ● pgAdmin: GUI front-end ● phpPgadmin: Web based front-end ● MS ODBC ● MS Office + Postgres ● NaviCat: $$ ● DeZign: $$ ● EMS SQL Manager for PostgreSQL: $$
  • 18. Data Types ● Numeric Types ● Character Types ● Hierarchical Types ● Binary Data Types ● Geometric Types ● Network Address Types ● Text Search Types ● UUID Type ● XML Type ● JSON Type ● Arrays ● Composite Types
  • 19. Indexes B-tree: B-trees can handle equality and range queries on data that can be sorted into some ordering (<, <=,=,>=,>) Hash: Hash indexes can only handle simple equality comparisons GIN: GIN indexes are inverted indexes which can handle values that contain more than one key, arrays for example, GIN operator classes for one-dimensional arrays (<@,@>,=,&&) GiST: Generalized Search Tree, it is a tree-structured access method and also known as two-dimensional geometric data types (<@,@>,=,&&,>>,<<,&<,>&,~=)
  • 20. Functions A stored procedure and user-defined function is a set of SQL and procedural statements (declarations, assignments, loops, flow-of-control) that stored on the database server and can be invoked using the SQL interface. CREATE FUNCTION function_name(p1 type, p2 type) RETURNS type AS BEGIN -- logic END; LANGUAGE language_name;
  • 21. Triggers On DML (Data Manipulation Language) SELECT, INSERT, UPDATE, DELETE CREATE TRIGGER name { BEFORE | AFTER } { event [ OR ... ] } ON table [ FOR [ EACH ] { ROW | STATEMENT } ] EXECUTE PROCEDURE funcname ( arguments )
  • 22. Cursors ● Used instead of FOR. ● Avoid memory overrun. ● Large data set. DECLARE curs1 refcursor; curs2 CURSOR FOR SELECT * FROM tenk1; OPEN curs1 FOR SELECT * FROM foo WHERE key = mykey; FETCH curs2 INTO foo, bar, baz; CLOSE curs1;
  • 23. View View consists of a stored query accessible as a virtual table in a relational database or a set of documents in a document-oriented database composed of the result set of a query. Views are a great way to simplify your data model. CREATE VIEW table_information AS SELECT * FROM table WHERE id = 123; Now you can simply query your new table directly: SELECT * FROM table_information;
  • 24. User-defined objects New types of almost all objects inside the database can be created, including: ● Casts ● Conversions ● Data types ● Domains ● Functions, including aggregate functions and window functions ● Indexes including custom indexes for custom types ● Operators (existing ones can be overloaded) ● Procedural languages
  • 25. Replication Methods 1. Master/Slave ● Asynchronous ● Synchronous 2. Multi-Master ● Asynchronous ● Synchronous 3. Proxy 4. Standby system
  • 26. Master/Slave Replication Asynchronous Synchronous High availability High availibility Read performance Better read performance Offline peers Worse write performance async M S M S sync
  • 27. Multi-Master Replication Asynchronous Synchronous Read performance High availiability Faster access across WANs Read performance Manage offline peers Difficult to get good write performance M M M M async sync
  • 30. Hierarchical Database Data is organized into a tree like structure. Representing information using parent/child relationships. Each parent can have many children, but each child has only one parent also known as a 1- to-many relationship. Different ways store data like this are • Enumeration path (ltree) • Adjacency List • Nested Sets
  • 31. LTree – Label Tree ● Ltree is a PostgreSQL module. ● It is implements a data type ltree for representing labels of data stored in a hierarchical tree-like structure. ● Labels must be less than 256 bytes long. ltree stores a label path. ● A label path is a sequence of zero or more labels separated by dots. ● ltree supports several types of indexes that can speed up the indicated operators. ● Ltree performance is much better when you need to do ad-hoc queries over the tree ● Faster than recursive function that constantly needs to recalculate the branching. ● Some other databases have similar types. SQL Server 2008 has a datatype called HierarchyID which serves the same purpose as ltree but with different syntax.
  • 32. Example Technique Adjacency Ltree Query WITH RECURSIVE d AS ( SELECT id FROM sponsorship WHERE id = 799 UNION ALL SELECT s.id FROM d JOIN sponsorship s ON s.parent_fk = d.id ) SELECT * FROM d ORDER BY id LIMIT 100; WITH p AS ( SELECT path FROM sponsorship WHERE id=799 ) SELECT s.id FROM sponsorship s, p WHERE s.path <@ p.path ORDER BY s.id LIMIT 100; Total Runtime 1946.48 ms 28.00 ms
  • 33. More Details 1. Value Expression http://www.postgresql.org/docs/9.2/static/sql-expressions.html 2. String Functions and Operators http://www.postgresql.org/docs/9.2/static/functions-string.html 3. Mathematical Functions and Operators http://www.postgresql.org/docs/9.2/static/functions-math.html 4. MySQL vs PostgreSQL http://get.enterprisedb.com/whitepapers/Postgres_Plus_8.4_vs_MySQL_5.5.pdf 5. Scaling Behaviour http://tweakers.net/reviews/657/1/database-test-dual-intel-xeon-5160-introduction.html