KEMBAR78
Heroku Postgres Cloud Database Webinar | PDF
Heroku	
  Postgres	
  Webinar


   Craig	
  Kerstiens


   Matt	
  Soldo
Architecture

                                                              Other
Force.com                Heroku Runtime
                                                            Platforms




       Database.com                       Heroku Postgres
Database.com       Social	
  Enterprise	
  DBaaS



Heroku	
  Postgres   SQL	
  Database-­‐as-­‐a-­‐Service
Let’s	
  Provision	
  a	
  Database
Value-Added Features




Heroku           Postgres
Postgres



           Management Services
Value-Added Features




Heroku           Postgres
Postgres



           Management Services
Management	
  Services
DBA	
  Tasks
    Setup

   Manage

   Security

   Backup

    Scale

    Query
DBA	
  Tasks
    Setup

   Manage

   Security

   Backup

    Scale

    Query
We	
  hold	
  the	
  pager

    Health	
  Checks

Continuous	
  Protection
Value-Added Features




Heroku           Postgres
Postgres



           Management Services
Value-Added Features




Heroku           Postgres
Postgres



           Management Services
100%	
  Compatible
Why	
  Postgres?
Users   Purchases




        Products
CREATE	
  TABLE	
  products	
  (
	
  	
  	
  	
  id	
  integer	
  NOT	
  NULL,
	
  	
  	
  	
  title	
  character	
  varying(255),
	
  	
  	
  	
  description	
  text,
	
  	
  	
  	
  price	
  numeric(10,2)
);
CREATE	
  TABLE	
  users	
  (
	
  	
  	
  	
  id	
  integer	
  NOT	
  NULL,
	
  	
  	
  	
  first_name	
  character	
  varying(50),
	
  	
  	
  	
  last_name	
  character	
  varying(50),
	
  	
  	
  	
  email	
  character	
  varying(255),
	
  	
  	
  	
  data	
  hstore,
	
  	
  	
  	
  created_at	
  timestamp	
  without	
  time	
  zone,
	
  	
  	
  	
  updated_at	
  timestamp	
  without	
  time	
  zone,
	
  	
  	
  	
  last_login	
  timestamp	
  with	
  time	
  zone
);
CREATE	
  TABLE	
  purchases	
  (
	
  	
  	
  	
  id	
  integer	
  NOT	
  NULL,
	
  	
  	
  	
  user_id	
  integer,
	
  	
  	
  	
  items	
  decimal(10,2)	
  [][],
	
  	
  	
  	
  occurred_at	
  timestamp
);
CREATE	
  TABLE	
  purchases	
  (
	
  	
  	
  	
  id	
  integer	
  NOT	
  NULL,
	
  	
  	
  	
  user_id	
  integer,
	
  	
  	
  	
  items	
  decimal(10,2)	
  [][],
	
  	
  	
  	
  occurred_at	
  timestamp
);
CREATE	
  TABLE	
  purchases	
  (
	
  	
  	
  	
  id	
  integer	
  NOT	
  NULL,
	
  	
  	
  	
  user_id	
  integer,
	
  	
  	
  	
  items	
  decimal(10,2)	
  [][],
	
  	
  	
  	
  occurred_at	
  timestamp
);
                                       items[x][0] = item_id
                                       items [x][1] = qty
                                       items [x][2] = price
Data	
  Types

INSERT	
  INTO	
  purchases	
  VALUES	
  (
	
  	
  2,	
  2,	
  '{{11.0,	
  1.0,	
  4.99}}',	
  now()
);
Data	
  Types
    bigint                            money
timestamptz   polygon         date              boolean interval
                        array           integer              UUID
             smallint                              char
     serial               bytea
                  line               numeric
     inet cidr                               point         circle
                         time   text                float
         macaddr                           timetz                enum
                   varchar        tsquery              XML
       path                   tsvector       timestamp         box
Other	
  Languages
CREATE	
  OR	
  REPLACE	
  FUNCTION	
  total(decimal(10,2)[][])	
  
RETURNS	
  decimal(10,2)	
  AS	
  $$
DECLARE
	
  	
  s	
  decimal(10,2)	
  :=	
  0;
	
  	
  x	
  decimal[];
BEGIN
	
  	
  FOREACH	
  x	
  SLICE	
  1	
  IN	
  ARRAY	
  $1
	
  	
  LOOP
	
  	
  	
  	
  s	
  :=	
  s	
  +	
  (x[2]	
  *	
  x[3]);
	
  	
  END	
  LOOP;
	
  	
  RETURN	
  s;
END;
$$	
  LANGUAGE	
  plpgsql;
Other	
  Languages

FOREACH	
  x	
  SLICE	
  1	
  IN	
  ARRAY	
  $1
	
  	
  LOOP
	
  	
  	
  	
  s	
  :=	
  s	
  +	
  (x[2]	
  *	
  x[3]);
	
  	
  END	
  LOOP;
	
  	
  RETURN	
  s;
Other	
  Languages

python     pgsql                                     lolcode
                      ruby              j
         lua                       V8             R
                    scheme
  tcl                        SQL            psm           Java
               sh       php             javascript
Extensions
CREATE	
  EXTENSION	
  hstore;
CREATE	
  TABLE	
  users	
  (
	
  	
  	
  	
  id	
  integer	
  NOT	
  NULL,
	
  	
  	
  	
  first_name	
  character	
  varying(50),
	
  	
  	
  	
  last_name	
  character	
  varying(50),
	
  	
  	
  	
  email	
  character	
  varying(255),
	
  	
  	
  	
  data	
  hstore,
	
  	
  	
  	
  created_at	
  timestamp	
  without	
  time	
  zone,
	
  	
  	
  	
  last_login	
  timestamp	
  without	
  time	
  zone
);
Extensions
INSERT	
  INTO	
  users	
  
VALUES	
  (
  1,	
  
  'Craig',	
  
  'Kerstiens',	
  
  'craig.kerstiens@gmail.com',	
  
  'sex	
  =>	
  "M",	
  state	
  =>	
  "CA"',	
  
  now(),	
  
  now()
);
Extensions
dblink   hstore           uuid-ossp trigram
                                              pgstattuple
        citext      pgcrypto       pgrowlocks
   isn             ltree earthdistance
         cube                                 dict_int
                tablefunc       fuzzystrmatch
  unaccent                                    dict_xsyn
                            btree_gist
Value-Added Features




Heroku           Postgres
Postgres



           Management Services
Value-Added Features




Heroku           Postgres
Postgres



           Management Services
Data	
  Clips
The	
  easiest	
  way	
  to	
  share	
  your	
  data
+
                      SELECT *
Your Live
                      FROM sales
Production Data       WHERE amount > 1
https://postgres.heroku.com/dataclips/{unique	
  &	
  secure	
  hash}
Followers
Master
Database


                      Write	
  Transactions
      Follower	
  1




      Follower	
  2
                      Read	
  Transactions
Followers
Master
Database


                      Write	
  Transactions
      Follower	
  1




      Follower	
  2
                      Read	
  Transactions
Followers
Master
Database


                      Write	
  Transactions
     New	
  Master




      Follower	
  2
                      Read	
  Transactions
Pricing	
  and	
  Availability
Learn	
  More

Try	
  It	
  free:	
  	
  	
  https://postgres.heroku.com

Code:	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  https://github.com/craigkerstiens/postgres-­‐demo

Survey:	
  	
  	
  	
  	
  	
  	
  	
  http://bit.ly/herokupostgressurvey


                    matt@heroku.com	
  	
  |	
  	
  craig@heroku.com

Heroku Postgres Cloud Database Webinar

  • 1.
    Heroku  Postgres  Webinar Craig  Kerstiens Matt  Soldo
  • 2.
    Architecture Other Force.com Heroku Runtime Platforms Database.com Heroku Postgres
  • 3.
    Database.com Social  Enterprise  DBaaS Heroku  Postgres SQL  Database-­‐as-­‐a-­‐Service
  • 4.
  • 5.
    Value-Added Features Heroku Postgres Postgres Management Services
  • 6.
    Value-Added Features Heroku Postgres Postgres Management Services
  • 7.
  • 8.
    DBA  Tasks Setup Manage Security Backup Scale Query
  • 9.
    DBA  Tasks Setup Manage Security Backup Scale Query
  • 10.
    We  hold  the  pager Health  Checks Continuous  Protection
  • 11.
    Value-Added Features Heroku Postgres Postgres Management Services
  • 12.
    Value-Added Features Heroku Postgres Postgres Management Services
  • 13.
  • 14.
  • 15.
    Users Purchases Products
  • 16.
    CREATE  TABLE  products  (        id  integer  NOT  NULL,        title  character  varying(255),        description  text,        price  numeric(10,2) );
  • 17.
    CREATE  TABLE  users  (        id  integer  NOT  NULL,        first_name  character  varying(50),        last_name  character  varying(50),        email  character  varying(255),        data  hstore,        created_at  timestamp  without  time  zone,        updated_at  timestamp  without  time  zone,        last_login  timestamp  with  time  zone );
  • 18.
    CREATE  TABLE  purchases  (        id  integer  NOT  NULL,        user_id  integer,        items  decimal(10,2)  [][],        occurred_at  timestamp );
  • 19.
    CREATE  TABLE  purchases  (        id  integer  NOT  NULL,        user_id  integer,        items  decimal(10,2)  [][],        occurred_at  timestamp );
  • 20.
    CREATE  TABLE  purchases  (        id  integer  NOT  NULL,        user_id  integer,        items  decimal(10,2)  [][],        occurred_at  timestamp ); items[x][0] = item_id items [x][1] = qty items [x][2] = price
  • 21.
    Data  Types INSERT  INTO  purchases  VALUES  (    2,  2,  '{{11.0,  1.0,  4.99}}',  now() );
  • 22.
    Data  Types bigint money timestamptz polygon date boolean interval array integer UUID smallint char serial bytea line numeric inet cidr point circle time text float macaddr timetz enum varchar tsquery XML path tsvector timestamp box
  • 23.
    Other  Languages CREATE  OR  REPLACE  FUNCTION  total(decimal(10,2)[][])   RETURNS  decimal(10,2)  AS  $$ DECLARE    s  decimal(10,2)  :=  0;    x  decimal[]; BEGIN    FOREACH  x  SLICE  1  IN  ARRAY  $1    LOOP        s  :=  s  +  (x[2]  *  x[3]);    END  LOOP;    RETURN  s; END; $$  LANGUAGE  plpgsql;
  • 24.
    Other  Languages FOREACH  x  SLICE  1  IN  ARRAY  $1    LOOP        s  :=  s  +  (x[2]  *  x[3]);    END  LOOP;    RETURN  s;
  • 25.
    Other  Languages python pgsql lolcode ruby j lua V8 R scheme tcl SQL psm Java sh php javascript
  • 26.
    Extensions CREATE  EXTENSION  hstore; CREATE  TABLE  users  (        id  integer  NOT  NULL,        first_name  character  varying(50),        last_name  character  varying(50),        email  character  varying(255),        data  hstore,        created_at  timestamp  without  time  zone,        last_login  timestamp  without  time  zone );
  • 27.
    Extensions INSERT  INTO  users   VALUES  ( 1,   'Craig',   'Kerstiens',   'craig.kerstiens@gmail.com',   'sex  =>  "M",  state  =>  "CA"',   now(),   now() );
  • 28.
    Extensions dblink hstore uuid-ossp trigram pgstattuple citext pgcrypto pgrowlocks isn ltree earthdistance cube dict_int tablefunc fuzzystrmatch unaccent dict_xsyn btree_gist
  • 29.
    Value-Added Features Heroku Postgres Postgres Management Services
  • 30.
    Value-Added Features Heroku Postgres Postgres Management Services
  • 31.
    Data  Clips The  easiest  way  to  share  your  data
  • 32.
    + SELECT * Your Live FROM sales Production Data WHERE amount > 1
  • 33.
  • 34.
    Followers Master Database Write  Transactions Follower  1 Follower  2 Read  Transactions
  • 35.
    Followers Master Database Write  Transactions Follower  1 Follower  2 Read  Transactions
  • 36.
    Followers Master Database Write  Transactions New  Master Follower  2 Read  Transactions
  • 37.
  • 38.
    Learn  More Try  It  free:      https://postgres.heroku.com Code:                        https://github.com/craigkerstiens/postgres-­‐demo Survey:                http://bit.ly/herokupostgressurvey matt@heroku.com    |    craig@heroku.com