Show nav
Heroku Dev Center
  • Get Started
  • Docs
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log inorSign up
View categories

Categories

  • Heroku Architecture
    • Dynos (app containers)
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Command Line
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery
    • Continuous Integration
  • Language Support
    • Node.js
    • Ruby
      • Rails Support
      • Working with Bundler
    • Python
      • Background Jobs in Python
      • Working with Django
    • Java
      • Working with Maven
      • Java Database Operations
      • Working with the Play Framework
      • Java Advanced Topics
    • PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
    • Heroku Redis
    • Apache Kafka on Heroku
    • Other Data Stores
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
    • Compliance
  • Heroku Enterprise
    • Private Spaces
      • Infrastructure Networking
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
    • Single Sign-on (SSO)
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Databases & Data Management
  • ›
  • Heroku Postgres
  • ›
  • Postgres Special Topics
  • ›
  • Extensions, PostGIS, and Full Text Search Dictionaries on Heroku Postgres

Extensions, PostGIS, and Full Text Search Dictionaries on Heroku Postgres

Last updated 30 July 2019

Table of Contents

  • Data types
  • Foreign Data Wrappers
  • Functions
  • Statistics
  • Index types
  • Full text search dictionaries
  • dblink
  • pg_stat_statements
  • PostGIS
  • Extensions That Are No Longer Supported

Extensions allow related pieces of functionality, such as datatypes and functions, to be bundled together and installed in a database with a single command. Heroku Postgres supports many Postgres extensions as well as features such as full text search that are not bundled as part of the extensions system. A beta version of the PostGIS spatial database extension is also available.

Query your database for the list of supported extensions:

$ echo 'show extwlist.extensions' | heroku pg:psql
     extwlist.extensions
-----------------------------
btree_gist,chkpass,cube,dblink,dict_int...

To create any supported extension, open a session with heroku pg:psql and run the appropriate command:

$ heroku pg:psql
psql (9.6.2)
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type "help" for help.

ad27m1eao6kqb1=> CREATE EXTENSION hstore;
CREATE EXTENSION
ad27m1eao6kqb1=>

Data types

  • Bloom provides space-efficent bloom filter indexes. create extension bloom

  • Case Insensitive Text. Case insensitive text datatype. Although strings stored in citext do retain case information, they are case insensitive when used in queries. create extension citext

  • Cube: Multi-dimensional cubes. create extension cube

  • HStore: Key value store inside Postgres. create extension hstore

  • Label Tree: Tree-like hierarchies, with associated functions. create extension ltree

  • Large Objects: Provides stream-style access to user data that is stored in a special large-object structure. create extension lo

  • Product Numbering: Store product IDs and serial numbers such as UPC ISBN and ISSN. create extension isn

  • Seg: Provides a type for representing segments or floating point intervals. create extension seg

Foreign Data Wrappers

  • postgres_fdw Allows a Postgres database to talk to another Postgres database as a foreign server.

Foreign data wrappers are not available for hobby tier databases.

Functions

  • Address Standardizer: Single line address parser that normalizes addresses around a set of defined rules create extension address_standardizer. A set of rules for US addresses is already included create extension address_standardizer_data_us.

  • Autoinc: Stores the next value of a sequence into an integer field. create extension autoinc

  • Earth Distance: Functions for calculating the distance between points on the earth. create extension earthdistance

  • Fuzzy Match: Another method for determining the similarity between strings. Limited UTF-8 support. create extension fuzzystrmatch.

  • Insert Username: Inserts the current user’s name into a text field. create extension insert_username

  • Intarray: Sorting, manipulate, and create indexes on null-free arrays of integers. create extension intarray

  • ModDateTime: Inserts the current timestamp into a timestamp field. create extension moddatetime

  • PGCrypto: Cryptographic functions allow for encryption within the database create extension pgcrypto.

  • pg_partman: Create and manage both time-based and serial-based table partition sets. Sub-partitoning is also supported.

  • pg_prewarm: Preload data into the operating system, or database buffer cache to help normalize performance on a freshly started, or quiescent database.

pg_partman and pg_prewarm are not available for hobby tier databases.

  • sslinfo: Provides functions to query SSL information about connecting clients. create extension sslinfo

  • Table Functions & Pivot Tables: Functions returning full tables, including the ability to manipulate query results in a manner similar to spreadsheet pivot tables create extension tablefunc.

  • tcn: Provides a trigger function for notifying listeners of changes to tables. create extension tcn

  • Timetravel: Adds functions for querying historical data. create extension timetravel

  • Trigram: Determine the similarity (or lack thereof) of alphanumeric string based on trigram matching. Useful for natural language processing problems such as search. create extension pg_trgm.

  • tsm_system_rows Provides table sampling via system rows.create extension tsm_system_rows

  • tsm_system_time Provides table sampling via system time.create extension tsm_system_time

  • UUID Generation: Generate v1, v3, v4, and v5 UUIDs in-database. Works great with the existing UUID datatype create extension "uuid-ossp".

Statistics

  • Row Locking: Show row lock information for a table. create extension pgrowlocks

Index types

  • btree-gist: A GiST index operator. It is generally inferior to the standard btree index, except for multi-column indexes that can’t be used with btree and exclusion constrations. create extension btree_gist

  • btree-gin: A GIN index operator. It is generally inferior to the standard btree index, except for developing new GIN operator classes or creating a multicolumn GIN index for both GIN-indexable and btree-indexable columns.

Full text search dictionaries

  • dict-int - A full-text search dictionary for full-text search which controls how integers are indexed. create extension dict_int

  • unaccent - A filtering text dictionary which removes accents from characters. create extension unaccent

Additionally, the following dictionaries are installed by default and don’t require creation via the extension system:

$ heroku pg:psql
=> \dFd
                             List of text search dictionaries
   Schema   |      Name       |                        Description
------------+-----------------+-------------------------------
 pg_catalog | danish_stem     | snowball stemmer for danish language
 pg_catalog | dutch_stem      | snowball stemmer for dutch language
 pg_catalog | english_stem    | snowball stemmer for english language
 pg_catalog | finnish_stem    | snowball stemmer for finnish language
 pg_catalog | french_stem     | snowball stemmer for french language
 pg_catalog | german_stem     | snowball stemmer for german language
 pg_catalog | hungarian_stem  | snowball stemmer for hungarian language
 pg_catalog | italian_stem    | snowball stemmer for italian language
 pg_catalog | norwegian_stem  | snowball stemmer for norwegian language
 pg_catalog | portuguese_stem | snowball stemmer for portuguese language
 pg_catalog | romanian_stem   | snowball stemmer for romanian language
 pg_catalog | russian_stem    | snowball stemmer for russian language
 pg_catalog | simple          | simple dictionary: just lower case and check for stopword
 pg_catalog | spanish_stem    | snowball stemmer for spanish language
 pg_catalog | swedish_stem    | snowball stemmer for swedish language
 pg_catalog | turkish_stem    | snowball stemmer for turkish language

dblink

dblink Adds support for querying between Postgres databases. With dblink you can query between separate Heroku Postgres databases or to/from external Postgres databases.

dblink is not available for hobby tier databases.

pg_stat_statements

pg_stat_statements:

The pg_stat_statements module provides a means for tracking execution statistics of all SQL statements executed by a server.

Usage

pg_stat_statements can be used to track performance problems. It provides a view called pg_stat_statements that displays each query that has been executed, and associated costs, including the number of times the query was executed, the total system time execution has taken in aggregate, and the total number of blocks in shared memory hit in aggregate.

pg_stat_statements does not capture any queries that were cancelled, no matter how long they ran beforehand. This means that long running queries cancelled by statement_timeout will not be reflected in the pg_stat_statements view. You will need to use the Postgres logs to diagnose expensive cancelled queries effectively.

PostGIS

PostGIS:

adds support for geographic objects to the PostgreSQL object-relational database. In effect, PostGIS “spatially enables” the PostgreSQL server, allowing it to be used as a backend spatial database for geographic information systems (GIS)

 

PostGIS support on Heroku Postgres is in beta and is subject to change in the future.

Requirements

Currently, PostGIS can only be used on Production tier Heroku Postgres plans and on hobby plans with Postgres version 9.4 and above. Additionally, PostGIS is only available as v2.2 with Postgres 9.5, 9.4 and 9.3 or as v2.1 with Postgres 9.4 and 9.3.

Provisioning

PostGIS support can be added like any other extension, as long as your database meets the requirements above.

$ heroku addons:create heroku-postgresql:standard-0

and then simply run create extension postgis. Note also that this functionality is only available on newer databases. If your database meets the requirements above but you still receive an error when running create extension postgis, you can use the fast changeover procedure to move to a fresh database with PostGIS support.

To detect if PostGIS is installed on a database, execute the following query from psql:

=> SELECT postgis_version();
        postgis_version
---------------------------------------
 2.1 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
(1 row)

Extensions That Are No Longer Supported

  • PLV8 - During the Heroku beta period for this extension, the PLV8 package maintenance was discontinued for PG11+ for Debian/Ubuntu. Read more here. Should this change, we may re-institute PLV8.

Keep reading

  • Postgres Special Topics
  • Choosing the Right Heroku Postgres Plan
  • Understanding Heroku Postgres Log Statements and Common Errors
  • Heroku Postgres Follower Databases

Feedback

Log in to submit feedback.

PostGIS: Using Geospatial Data with Rails

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Podcasts
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing

Subscribe to our monthly newsletter

  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Heroku Podcasts
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Facebook
  • Instagram
  • Github
  • LinkedIn
Heroku is acompany

 © Salesforce.com

  • heroku.com
  • Terms of Service
  • Privacy
  • Cookies