SlideShare a Scribd company logo
Extensions on PostgreSQL

                               Ever and Will
                      Hitoshi Harada @ FORCIA, Inc.



©2011 FORCIA, Inc.
Extensions on PostgreSQL




©2011 FORCIA, Inc.
Outline

    • Extensibility of PostgreSQL

    • Core extensions

    • Common extensions

    • CREATE EXTENSION

    • PGXN, a.k.a. “PostgreSQL Extension Network”

©2011 FORCIA, Inc.
Extensibility of PostgreSQL


                                                dblink, adminpack, pgcrypto, ...

                       Parser
                                                cube, ltree, citext, hstore, json, …
    Functions        Data Types   PL
                                                pl/R, pl/v8js, pl/Ruby, pl/Lua, …
                     Optimizer
                                                 pgadviser
                      Executor

                       Table                     auto_explain

                       Index
                                               GiST/GIN,
                                               textsearch_senna, textsearch_groonga
  SQL/MED (9.1!)

                                       c.f. external tools: pgpool, slony, pg_bulkload…

©2011 FORCIA, Inc.
Core Extensions

    •    intagg - int_array_aggregate()
    •    intarray - sort(), uniq()
    •    hstore - ‘a=>1, b=>2’->’a’
    •    citext - case insensitive text
    •    cube - (1.5, 2.0, 0.5)
    •    pgcrypto - digest() -- md5, sha1
    •    dblink - dblink_exec(connstr, sql)
    •    earthdistance - earth()
    •    …and more

©2011 FORCIA, Inc.
Common Extensions

    •    PostGIS
    •    Pgmemchache - memcache_[get|add|set]()
    •    SkyTools
    •    OracleFCE - nvl(), reverse(), etc.
    •    pgSphere
    •    pgTAP - ok(val, expected)
    •    textsearch_senna
    •    json
    •    PL & FDW
©2011 FORCIA, Inc.
PLs…

    •    PL/perl      •   PL/sh
    •    PL/python    •   PL/scheme
    •    PL/tcl       •   PL/proxy
    •    PL/ruby      •   PL/js
    •    PL/php       •   PL/v8js
    •    PL/java      •   PL/whitespace – coming soon!
    •    PL/R         •   PL/brainfuck
                          CREATE FUNCTION bf_add(int, int) RETURNS int AS
    •    PL/lua              $$ >>>>[-<<<<+>>>>] $$
                          LANGUAGE brainfuck;
    •    PL/lolcode       SELECT * FROM bf_add(3, 5); -- 8!


©2011 FORCIA, Inc.
FDWs (Foreign Data Wrapper)

    • file_fdw
    • postgresql_fdw
    • twitter_fdw
            SELECT from_user, substr(text, 1, 20), age(current_timestamp, created_at)
            FROM twitter_search WHERE q =‘#iphone’;
             from_user       |        substr        |      age
            -----------------+----------------------+----------------
             anndreilla      | Grab @Scrambleface l | 09:02:19.76668
             tebow904        | @sinner_saved_ u ret | 09:02:30.76668
             iphomania_de    | Cydia-Tweak: Pull to | 09:02:31.76668
             developerworks | The #Social #Network | 09:02:34.76668
             appstorewire    | AppAdvice: Project: | 09:02:42.76668
             appstorewire    | AppAdvice: Project: | 09:02:42.76668
             appstorewire    | AppAdvice: A Chance | 09:02:42.76668
             appstorewire    | AppAdvice: A Chance | 09:02:42.76668
             appstorewire    | AppAdvice: Infinity | 09:02:43.76668
             appstorewire    | AppAdvice: Infinity | 09:02:43.76668
             ChrisCompo      | RT @thedroidguy: #iP | 09:02:46.76668
             DhilipSiva_Aple | #ipad #mac #iphone i | 09:02:48.76668
             brandnewapps    | New iPmart app: iNet | 09:02:48.76668
             brandnewapps    | New iPmart app: A Ne | 09:02:49.76668
             muenchner_kindl | Hard Rock Mobile     | 09:02:59.76668
            (15 rows)

©2011 FORCIA, Inc.
CREATE EXTENSION

    • Proposed for 9.1 Committed for 9.1
             $ psql –d dbname –f /path/to/contrib/hstore.sql


             db=# CREATE EXTENSION hstore;
             CREATE EXTENSION
             db1=# SELECT 'a=>1, b=>2'::hstore;
                  hstore
             --------------------
              "a"=>"1", "b"=>"2"
             (1 row)

             db1=# DROP EXTENSION hstore;
             DROP EXTENSION


    • EASY pg_dump/pg_restore, and DROP. Yay!
©2011 FORCIA, Inc.
PGXN , a.k.a. “PostgreSQL Extension Network”

    • By David E. Wheeler
    • Inspired by CPAN
           – [user@host] $ pgxn install hstore
    • Under development…




©2011 FORCIA, Inc.
Try to make YOUR extensions!


  CREATE OR REPLACE FUNCTION is_timezone(
    tz CITEXT
  ) RETURNS BOOLEAN LANGUAGE plpgsql STABLE AS $$
  BEGIN
    PERFORM NOW() AT TIME ZONE tz;
    RETURN TRUE;
  EXCEPTION WHEN invalid_parameter_value THEN
    RETURN FALSE;
  END;
  $$;
  CREATE DOMAIN timezone AS CITEXT
    CHECK ( is_timezone( VALUE ) );

                                http://blog.pgxn.org/post/1673708474/slides-manager-work


©2011 FORCIA, Inc.
Conclusion



    • You can use rich extensions already.

    • You can make and upload your extension.

    • PostgreSQL is an application platform.




©2011 FORCIA, Inc.

More Related Content

What's hot (20)

PPTX
PostgreSQL Hangout Parameter Tuning
Ashnikbiz
 
PDF
Lessons PostgreSQL learned from commercial databases, and didn’t
PGConf APAC
 
PDF
PostgreSQL Extensions: A deeper look
Jignesh Shah
 
PDF
High Availability PostgreSQL with Zalando Patroni
Zalando Technology
 
PDF
PGConf.ASIA 2019 Bali - Performance Analysis at Full Power - Julien Rouhaud
Equnix Business Solutions
 
PDF
PostgreSQL for Oracle Developers and DBA's
Gerger
 
PDF
10 Reasons to Start Your Analytics Project with PostgreSQL
Satoshi Nagayasu
 
PDF
On The Building Of A PostgreSQL Cluster
Srihari Sriraman
 
ODP
PostgreSQL Replication in 10 Minutes - SCALE
PostgreSQL Experts, Inc.
 
PDF
Streaming replication in practice
Alexey Lesovsky
 
PDF
Elephants in the Cloud
Mike Fowler
 
PDF
PostgreSQL Enterprise Class Features and Capabilities
PGConf APAC
 
PDF
Streaming Replication (Keynote @ PostgreSQL Conference 2009 Japan)
Masao Fujii
 
PDF
Linux tuning to improve PostgreSQL performance
PostgreSQL-Consulting
 
PDF
Как PostgreSQL работает с диском
PostgreSQL-Consulting
 
PDF
The Accidental DBA
PostgreSQL Experts, Inc.
 
PDF
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL-Consulting
 
PDF
Oracle to Postgres Migration - part 2
PgTraining
 
ODP
Shootout at the AWS Corral
PostgreSQL Experts, Inc.
 
PDF
Overview of Postgres Utility Processes
EDB
 
PostgreSQL Hangout Parameter Tuning
Ashnikbiz
 
Lessons PostgreSQL learned from commercial databases, and didn’t
PGConf APAC
 
PostgreSQL Extensions: A deeper look
Jignesh Shah
 
High Availability PostgreSQL with Zalando Patroni
Zalando Technology
 
PGConf.ASIA 2019 Bali - Performance Analysis at Full Power - Julien Rouhaud
Equnix Business Solutions
 
PostgreSQL for Oracle Developers and DBA's
Gerger
 
10 Reasons to Start Your Analytics Project with PostgreSQL
Satoshi Nagayasu
 
On The Building Of A PostgreSQL Cluster
Srihari Sriraman
 
PostgreSQL Replication in 10 Minutes - SCALE
PostgreSQL Experts, Inc.
 
Streaming replication in practice
Alexey Lesovsky
 
Elephants in the Cloud
Mike Fowler
 
PostgreSQL Enterprise Class Features and Capabilities
PGConf APAC
 
Streaming Replication (Keynote @ PostgreSQL Conference 2009 Japan)
Masao Fujii
 
Linux tuning to improve PostgreSQL performance
PostgreSQL-Consulting
 
Как PostgreSQL работает с диском
PostgreSQL-Consulting
 
The Accidental DBA
PostgreSQL Experts, Inc.
 
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL-Consulting
 
Oracle to Postgres Migration - part 2
PgTraining
 
Shootout at the AWS Corral
PostgreSQL Experts, Inc.
 
Overview of Postgres Utility Processes
EDB
 

Viewers also liked (8)

PDF
EXPLicando o Explain no PostgreSQL
Fabrízio Mello
 
PDF
DevOps e PostgreSQL: Replicação de forma simplificada | Miguel Di Ciurcio
PGDay Campinas
 
PDF
石狩DCで運用するプライベートクラウドとハイブリッドクラウドへの展望(既存資産とクラウドの価値を生かすハイブリッドクラウド事例セミナー)
さくらインターネット株式会社
 
PDF
NoSQL + SQL = PostgreSQL (TDC2014 - Porto Alegre/RS)
Fabrízio Mello
 
PDF
PGDay Campinas 2013 - PL/pg…ETL – Transformação de dados para DW e BI usando ...
PGDay Campinas
 
PDF
Planejador de Consultas do PostgreSQL
Fabrízio Mello
 
PDF
PostgreSQL: How to Store Passwords Safely
Juliano Atanazio
 
PDF
[db tech showcase Tokyo 2016] C32: 世界一速いPostgreSQLを目指せ!インメモリカラムナの実現 by 富士通株式会...
Insight Technology, Inc.
 
EXPLicando o Explain no PostgreSQL
Fabrízio Mello
 
DevOps e PostgreSQL: Replicação de forma simplificada | Miguel Di Ciurcio
PGDay Campinas
 
石狩DCで運用するプライベートクラウドとハイブリッドクラウドへの展望(既存資産とクラウドの価値を生かすハイブリッドクラウド事例セミナー)
さくらインターネット株式会社
 
NoSQL + SQL = PostgreSQL (TDC2014 - Porto Alegre/RS)
Fabrízio Mello
 
PGDay Campinas 2013 - PL/pg…ETL – Transformação de dados para DW e BI usando ...
PGDay Campinas
 
Planejador de Consultas do PostgreSQL
Fabrízio Mello
 
PostgreSQL: How to Store Passwords Safely
Juliano Atanazio
 
[db tech showcase Tokyo 2016] C32: 世界一速いPostgreSQLを目指せ!インメモリカラムナの実現 by 富士通株式会...
Insight Technology, Inc.
 
Ad

Similar to Extensions on PostgreSQL (20)

PDF
groonga with PostgreSQL
Akihiro Okuno
 
PDF
Beyond Postgres: Interesting Projects, Tools and forks
Sameer Kumar
 
PDF
Heroku Postgres SQL Tips, Tricks, Hacks
Salesforce Developers
 
PDF
Heroku Postgres Cloud Database Webinar
Salesforce Developers
 
PDF
JDD 2016 - Tomasz Borek - DB for next project? Why, Postgres, of course
PROIDEA
 
PDF
Going beyond Django ORM limitations with Postgres
Craig Kerstiens
 
KEY
Building and Distributing PostgreSQL Extensions Without Learning C
David Wheeler
 
PDF
From SQLAlchemy to Ming with TurboGears2
Alessandro Molina
 
PDF
Rails israel 2013
Reuven Lerner
 
PDF
PostgreSQL, Extensible to the Nth Degree: Functions, Languages, Types, Rules,...
Command Prompt., Inc
 
KEY
PostgreSQL
Reuven Lerner
 
PPTX
PostgreSQL - It's kind've a nifty database
Barry Jones
 
PDF
Postgres demystified
Craig Kerstiens
 
PDF
PGDay.Amsterdam 2018 - Bruce Momjian - Will postgres live forever
PGDay.Amsterdam
 
PDF
9.1 Grand Tour
PostgreSQL Experts, Inc.
 
PDF
Postgres Vision 2018: Will Postgres Live Forever?
EDB
 
PDF
9.1 Mystery Tour
PostgreSQL Experts, Inc.
 
PPTX
Postgres level up
Fabio Telles Rodriguez
 
PDF
Pl/Python
Command Prompt., Inc
 
PDF
An evening with Postgresql
Joshua Drake
 
groonga with PostgreSQL
Akihiro Okuno
 
Beyond Postgres: Interesting Projects, Tools and forks
Sameer Kumar
 
Heroku Postgres SQL Tips, Tricks, Hacks
Salesforce Developers
 
Heroku Postgres Cloud Database Webinar
Salesforce Developers
 
JDD 2016 - Tomasz Borek - DB for next project? Why, Postgres, of course
PROIDEA
 
Going beyond Django ORM limitations with Postgres
Craig Kerstiens
 
Building and Distributing PostgreSQL Extensions Without Learning C
David Wheeler
 
From SQLAlchemy to Ming with TurboGears2
Alessandro Molina
 
Rails israel 2013
Reuven Lerner
 
PostgreSQL, Extensible to the Nth Degree: Functions, Languages, Types, Rules,...
Command Prompt., Inc
 
PostgreSQL
Reuven Lerner
 
PostgreSQL - It's kind've a nifty database
Barry Jones
 
Postgres demystified
Craig Kerstiens
 
PGDay.Amsterdam 2018 - Bruce Momjian - Will postgres live forever
PGDay.Amsterdam
 
9.1 Grand Tour
PostgreSQL Experts, Inc.
 
Postgres Vision 2018: Will Postgres Live Forever?
EDB
 
9.1 Mystery Tour
PostgreSQL Experts, Inc.
 
Postgres level up
Fabio Telles Rodriguez
 
An evening with Postgresql
Joshua Drake
 
Ad

Recently uploaded (20)

PDF
Simplify Your FME Flow Setup: Fault-Tolerant Deployment Made Easy with Packer...
Safe Software
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
PDF
How to Visualize the ​Spatio-Temporal Data Using CesiumJS​
SANGHEE SHIN
 
PDF
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
Fwdays
 
PDF
TrustArc Webinar - Navigating APAC Data Privacy Laws: Compliance & Challenges
TrustArc
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
PPSX
Usergroup - OutSystems Architecture.ppsx
Kurt Vandevelde
 
PDF
Automating the Geo-Referencing of Historic Aerial Photography in Flanders
Safe Software
 
PPTX
Mastering Authorization: Integrating Authentication and Authorization Data in...
Hitachi, Ltd. OSS Solution Center.
 
PPTX
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
PDF
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
PDF
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
PDF
Bridging CAD, IBM TRIRIGA & GIS with FME: The Portland Public Schools Case
Safe Software
 
PPTX
Smart Factory Monitoring IIoT in Machine and Production Operations.pptx
Rejig Digital
 
PPTX
Reimaginando la Ciberdefensa: De Copilots a Redes de Agentes
Cristian Garcia G.
 
PDF
Why aren't you using FME Flow's CPU Time?
Safe Software
 
PDF
Understanding The True Cost of DynamoDB Webinar
ScyllaDB
 
PDF
Plugging AI into everything: Model Context Protocol Simplified.pdf
Abati Adewale
 
PDF
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 
Simplify Your FME Flow Setup: Fault-Tolerant Deployment Made Easy with Packer...
Safe Software
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
How to Visualize the ​Spatio-Temporal Data Using CesiumJS​
SANGHEE SHIN
 
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
Fwdays
 
TrustArc Webinar - Navigating APAC Data Privacy Laws: Compliance & Challenges
TrustArc
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
Usergroup - OutSystems Architecture.ppsx
Kurt Vandevelde
 
Automating the Geo-Referencing of Historic Aerial Photography in Flanders
Safe Software
 
Mastering Authorization: Integrating Authentication and Authorization Data in...
Hitachi, Ltd. OSS Solution Center.
 
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
Bridging CAD, IBM TRIRIGA & GIS with FME: The Portland Public Schools Case
Safe Software
 
Smart Factory Monitoring IIoT in Machine and Production Operations.pptx
Rejig Digital
 
Reimaginando la Ciberdefensa: De Copilots a Redes de Agentes
Cristian Garcia G.
 
Why aren't you using FME Flow's CPU Time?
Safe Software
 
Understanding The True Cost of DynamoDB Webinar
ScyllaDB
 
Plugging AI into everything: Model Context Protocol Simplified.pdf
Abati Adewale
 
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 

Extensions on PostgreSQL

  • 1. Extensions on PostgreSQL Ever and Will Hitoshi Harada @ FORCIA, Inc. ©2011 FORCIA, Inc.
  • 3. Outline • Extensibility of PostgreSQL • Core extensions • Common extensions • CREATE EXTENSION • PGXN, a.k.a. “PostgreSQL Extension Network” ©2011 FORCIA, Inc.
  • 4. Extensibility of PostgreSQL dblink, adminpack, pgcrypto, ... Parser cube, ltree, citext, hstore, json, … Functions Data Types PL pl/R, pl/v8js, pl/Ruby, pl/Lua, … Optimizer pgadviser Executor Table auto_explain Index GiST/GIN, textsearch_senna, textsearch_groonga SQL/MED (9.1!) c.f. external tools: pgpool, slony, pg_bulkload… ©2011 FORCIA, Inc.
  • 5. Core Extensions • intagg - int_array_aggregate() • intarray - sort(), uniq() • hstore - ‘a=>1, b=>2’->’a’ • citext - case insensitive text • cube - (1.5, 2.0, 0.5) • pgcrypto - digest() -- md5, sha1 • dblink - dblink_exec(connstr, sql) • earthdistance - earth() • …and more ©2011 FORCIA, Inc.
  • 6. Common Extensions • PostGIS • Pgmemchache - memcache_[get|add|set]() • SkyTools • OracleFCE - nvl(), reverse(), etc. • pgSphere • pgTAP - ok(val, expected) • textsearch_senna • json • PL & FDW ©2011 FORCIA, Inc.
  • 7. PLs… • PL/perl • PL/sh • PL/python • PL/scheme • PL/tcl • PL/proxy • PL/ruby • PL/js • PL/php • PL/v8js • PL/java • PL/whitespace – coming soon! • PL/R • PL/brainfuck CREATE FUNCTION bf_add(int, int) RETURNS int AS • PL/lua $$ >>>>[-<<<<+>>>>] $$ LANGUAGE brainfuck; • PL/lolcode SELECT * FROM bf_add(3, 5); -- 8! ©2011 FORCIA, Inc.
  • 8. FDWs (Foreign Data Wrapper) • file_fdw • postgresql_fdw • twitter_fdw SELECT from_user, substr(text, 1, 20), age(current_timestamp, created_at) FROM twitter_search WHERE q =‘#iphone’; from_user | substr | age -----------------+----------------------+---------------- anndreilla | Grab @Scrambleface l | 09:02:19.76668 tebow904 | @sinner_saved_ u ret | 09:02:30.76668 iphomania_de | Cydia-Tweak: Pull to | 09:02:31.76668 developerworks | The #Social #Network | 09:02:34.76668 appstorewire | AppAdvice: Project: | 09:02:42.76668 appstorewire | AppAdvice: Project: | 09:02:42.76668 appstorewire | AppAdvice: A Chance | 09:02:42.76668 appstorewire | AppAdvice: A Chance | 09:02:42.76668 appstorewire | AppAdvice: Infinity | 09:02:43.76668 appstorewire | AppAdvice: Infinity | 09:02:43.76668 ChrisCompo | RT @thedroidguy: #iP | 09:02:46.76668 DhilipSiva_Aple | #ipad #mac #iphone i | 09:02:48.76668 brandnewapps | New iPmart app: iNet | 09:02:48.76668 brandnewapps | New iPmart app: A Ne | 09:02:49.76668 muenchner_kindl | Hard Rock Mobile | 09:02:59.76668 (15 rows) ©2011 FORCIA, Inc.
  • 9. CREATE EXTENSION • Proposed for 9.1 Committed for 9.1 $ psql –d dbname –f /path/to/contrib/hstore.sql db=# CREATE EXTENSION hstore; CREATE EXTENSION db1=# SELECT 'a=>1, b=>2'::hstore; hstore -------------------- "a"=>"1", "b"=>"2" (1 row) db1=# DROP EXTENSION hstore; DROP EXTENSION • EASY pg_dump/pg_restore, and DROP. Yay! ©2011 FORCIA, Inc.
  • 10. PGXN , a.k.a. “PostgreSQL Extension Network” • By David E. Wheeler • Inspired by CPAN – [user@host] $ pgxn install hstore • Under development… ©2011 FORCIA, Inc.
  • 11. Try to make YOUR extensions! CREATE OR REPLACE FUNCTION is_timezone( tz CITEXT ) RETURNS BOOLEAN LANGUAGE plpgsql STABLE AS $$ BEGIN PERFORM NOW() AT TIME ZONE tz; RETURN TRUE; EXCEPTION WHEN invalid_parameter_value THEN RETURN FALSE; END; $$; CREATE DOMAIN timezone AS CITEXT CHECK ( is_timezone( VALUE ) ); http://blog.pgxn.org/post/1673708474/slides-manager-work ©2011 FORCIA, Inc.
  • 12. Conclusion • You can use rich extensions already. • You can make and upload your extension. • PostgreSQL is an application platform. ©2011 FORCIA, Inc.