Your SlideShare is downloading. ×
0
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Heroku Postgres SQL Tips, Tricks, Hacks
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Heroku Postgres SQL Tips, Tricks, Hacks

956

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
956
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Heroku PostgresSQL Tips, Tricks, HacksCraig Kerstiens, Heroku, Growth Hacker@craigkerstiens
  • 2. Safe Harbor Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward- looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of intellectual property and other litigation, risks associated with possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-Q for the most recent fiscal quarter ended July 31, 2012. This documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
  • 3. Craig KerstiensGrowth Hacker@craigkerstiens
  • 4. DISCLAIMERSQL Ahead
  • 5. Why Postgres“ its the emacs of databases”
  • 6. Datatypes date UUID timestamptz boolean array bigint interval integer smallint line XML enum money char serial bytea point floatinet polygon numeric circle cidr varchar tsquery timetz path time text macaddr timestamp box tsvector Datatypes | Custom Languages | Extensions | NoSQL | Window Functions |
  • 7. DatatypesCREATE TABLE purchases ( id integer NOT NULL, user_id integer, items[x][0] = item_iditems [x][1 items [x][2] = price Datatypes | Custom Languages | Extensions | NoSQL | Window Functions |
  • 8. DatatypesINSERT INTO purchases 25.0}, {15.0, 1.0, 25.0}}, now());VALUES (1, 37, {{15.0, 1.0,INSERT INTO purchases 4.99}}, now());VALUES (2, 2, {{11.0, 1.0, Datatypes | Custom Languages | Extensions | NoSQL | Window Functions |
  • 9. Datatypes date UUID timestamptz boolean array bigint interval integer smallint line XML enum money char serial bytea point floatinet polygon numeric circle cidr varchar tsquery timetz path time text macaddr timestamp box tsvector Datatypes | Custom Languages | Extensions | NoSQL | Window Functions |
  • 10. Languagespython ruby j lolcode pgsql V8 R lua scheme psmtcl SQL Java sh javascript php Datatypes | Custom Languages | Extensions | NoSQL | Window Functions |
  • 11. LanguagesCREATE OR REPLACE FUNCTION total(decimal(10,2)[][]) RETURNSdecimal(10,2) AS $$DECLARE s decimal(10,2) := 0; x decimal[];BEGINFOREACH x SLICE 1 IN ARRAY $1 LOOP s := s + (x[2] * x[3]); END LOOP;RETURN s;END;$$ LANGUAGE plpgsql; Datatypes | Custom Languages | Extensions | NoSQL | Window Functions |
  • 12. LanguagesFOREACH x SLICE 1 IN ARRAY $1 LOOP s := s + Datatypes | Custom Languages | Extensions | NoSQL | Window Functions |
  • 13. Extensions dblink hstore trigram uuid-ossp pgstattuple citext pgrowlocks pgcrypto isn ltree fuzzystrmatch cube earthdistancedict_int tablefuncunaccent btree_gist dict_xsyn Datatypes | Custom Languages | Extensions | NoSQL | Window Functions |
  • 14. ExtensionsCREATE EXTENSION hstore;CREATE TABLE users ( id integer NOT NULL, first_namecharacter varying(50), last_name character varying(50), emailcharacter varying(255), data hstore, created_at timestamp withouttime zone, last_login timestamp without time zone); Datatypes | Custom Languages | Extensions | NoSQL | Window Functions |
  • 15. ExtensionsINSERT INTO usersVALUES (1,Craig,Kerstiens,craig.kerstiens@gmail.com,sex => "M",now(),now()); Datatypes | Custom Languages | Extensions | NoSQL | Window Functions |
  • 16. Window FunctionsExample:Biggest spender bystate Datatypes | Custom Languages | Extensions | NoSQL | Window Functions |
  • 17. Window FunctionsSELECTemail,users.data->state,sum(total(items)),rank() OVER (PARTITION BY users.data->state ORDER BY sum(total(items)) desc)FROMusers, purchasesWHERE purchases.user_id = users.idGROUP BY 1, 2; Datatypes | Custom Languages | Extensions | NoSQL | Window Functions |
  • 18. Foreign Data Wrappers oracle mysql odbc twitter sybaseredis jdbc files couch s3 www ldap database.com informix Datatypes | Custom Languages | Extensions | NoSQL | Window Functions |
  • 19. Foreign Data WrappersCREATE EXTENSION redis_fdw;CREATE SERVER redis_server FOREIGN DATA WRAPPER redis_fdw OPTIONS (address 127.0.0.1, port 6379);CREATE FOREIGN TABLEredis_db0 (key text, value text) SERVER redis_server OPTIONS (database0);CREATE USER MAPPING FOR PUBLIC SERVER redis_server OPTIONS (password secret); Datatypes | Custom Languages | Extensions | NoSQL | Window Functions |
  • 20. Etc.CREATE INDEX Doesn’t lock tabCONCURRENTLY; Datatypes | Custom Languages | Extensions | NoSQL | Window Functions |
  • 21. Etc.CREATE INDEX Indexes only onCONCURRENTLY; conditionCREATE INDEX ON fooWHERE x=y; Datatypes | Custom Languages | Extensions | NoSQL | Window Functions |
  • 22. Etc.CREATE INDEXCONCURRENTLY; Pub sub in PostgCREATE INDEX ON fooWHERE x=y;Listen/Notify Datatypes | Custom Languages | Extensions | NoSQL | Window Functions |
  • 23. Why PostgresOpen CommunityBroad feature set(datatypes, extensions, functions, foreign datawrappers, etc)Reliability
  • 24. Craig KerstiensGrowth Hacker@craigkerstiens

×