42
http://postgres.heroku.com ウィル・ラインウェバー @leinweber Heroku,Inc.

Heroku Postgres

Embed Size (px)

DESCRIPTION

2012年12月6日 Cloudforce Japan Developer Zone内のシアターで講演された資料です。

Citation preview

Page 1: Heroku Postgres

http://postgres.heroku.com

ウィル・ラインウェバー@leinweber

Heroku,Inc.

Page 2: Heroku Postgres

アーキテクチャArchitecture

Heroku 実行環境Heroku Runtime

Database.com Heroku Postgres

Force.com その他Others

Page 3: Heroku Postgres

Heroku Postgres

Social Enterprise DBaaS

SQL Database-as-a-Service

Database.com

Page 4: Heroku Postgres

データベースをつくってみようLet’s Provision a Database

Page 5: Heroku Postgres

heroku addons:add heroku-postgres:dev -a will

Page 6: Heroku Postgres

Heroku Postgres

マネージドサービスManagement Services

Postgres

拡張機能Value-Added Features

Page 7: Heroku Postgres

Heroku Postgres

マネージドサービスManagement Services

Postgres

拡張機能Value-Added Features

Page 8: Heroku Postgres

マネージドサービスManaged Services

Page 9: Heroku Postgres

セットアップSetup

管理・監視Manage

セキュリティSecurity

バックアップBackup

拡張Scale

データ定義/抽出Query

DB管理者の仕事DBA Tasks

Page 10: Heroku Postgres

セットアップSetup

管理・監視Manage

セキュリティSecurity

バックアップBackup

拡張Scale

データ定義/抽出Query

DB管理者の仕事DBA Tasks

Page 11: Heroku Postgres

24x365 監視体制24x365 Monitoring

ヘルスチェックHealth Checks

継続的なデータ保全Continuous Protection

Page 12: Heroku Postgres

Heroku Postgres

マネージドサービスManagement Services

Postgres

拡張機能Value-Added Features

Page 13: Heroku Postgres

Postgres

Page 14: Heroku Postgres

100% 互換100% Compatibility

Page 15: Heroku Postgres

なぜPostgresなのか?Why Postgres?

Page 16: Heroku Postgres

Users Purchases

Products

Page 17: Heroku Postgres

CREATE TABLE products (    id integer NOT NULL,    title character varying(255),    description text,    price numeric(10,2));

Page 18: Heroku Postgres

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);

Page 19: Heroku Postgres

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] = qtyitems [x][2] = price

Page 20: Heroku Postgres

INSERT INTO purchases VALUES ( 2, 2, '{{11.0, 1.0, 4.99}}', now());

データ型Data types

Page 21: Heroku Postgres

smallint

bigint

integernumeric

floatserial

money

char

varchartext

bytea

timestamp

timestamptz

date

time timetz

intervalboolean

enumpointline

polygon

box

circle

path

inet cidrmacaddr

tsvectortsquery

array

XML

UUID

その他の言語Other languadges

Page 22: Heroku Postgres

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 languadges

Page 23: Heroku Postgres

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

その他の言語Other languadges

Page 24: Heroku Postgres

pythonrubypgsql

SQLtclsh

RV8Java

javascript

lolcode

scheme

php

j

luapsm

その他の言語Other languadges

Page 25: Heroku Postgres

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);

エクステンションExtention

Page 26: Heroku Postgres

INSERT INTO users VALUES (

1, 'Craig', 'Kerstiens', '[email protected]', 'sex => "M", state => "CA"', now(), now()

);

エクステンションExtention

Page 27: Heroku Postgres

エクステンションExtention

dblink hstorecitext

ltreeisncube

pgcrypto

tablefunc

uuid-ossp

earthdistance

trigram

fuzzystrmatch

pgrowlockspgstattuple

btree_gist

dict_intdict_xsynunaccent

Page 28: Heroku Postgres

Heroku Postgres

マネージドサービスManagement Services

Postgres

拡張機能Value-Added Features

Page 29: Heroku Postgres

拡張機能Value-Added Features

Page 30: Heroku Postgres

Data Clipsデータを共有する最も簡単な方法

The easiest way to share your data

Page 31: Heroku Postgres

SELECT * FROM salesWHERE amount > 1

+本番データLive Production Data

Page 32: Heroku Postgres

https://postgres.heroku.com/dataclips/{unique & secure hash}

Page 33: Heroku Postgres
Page 34: Heroku Postgres

Forkデータベースを完全な複製を作成

A perfect, byte-for-byte clone of your database

Page 35: Heroku Postgres

Fork

ProductionApp

Page 36: Heroku Postgres

Fork

ProductionApp

Page 37: Heroku Postgres

Fork

ProductionApp

データの内部を安全に調査Investigate data safty

Page 38: Heroku Postgres

Followワンクリックでレプリケーションを作成

Read replicas with a single click

Page 39: Heroku Postgres

Follow

Follower 1

Follower 2

書き込みトランザクションWrite Transactions

読み出しトランザクションRead Transactions

MasterDatabase

Page 40: Heroku Postgres

Follower 1

Follower 2

書き込みトランザクションWrite Transactions

読み出しトランザクションRead Transactions

MasterDatabase

Page 41: Heroku Postgres

Follower 2

書き込みトランザクションWrite Transactions

読み出しトランザクションRead Transactions

MasterDatabase

New Master