Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×

SFPUG Lightning Talk

Weitere Verwandte Inhalte

Ähnliche Bücher

Kostenlos mit einer 30-tägigen Testversion von Scribd

Alle anzeigen

Ähnliche Hörbücher

Kostenlos mit einer 30-tägigen Testversion von Scribd

Alle anzeigen

SFPUG Lightning Talk

  1. 1. Retroactive Analytics With Distributed PostgreSQL Dan Robinson Heap
  2. 2. ● Heap: web/iOS analytics that captures everything
  3. 3. ● Heap: web/iOS analytics that captures everything ● Making this interactive is hard!
  4. 4. app_id user_id properties HSTORE events HSTORE[] 12345 102756 email=>’coolguy@mail.com’, ab_test_grp=>’A’ ... 12345 300732 ab_test_grp=>’B’ ... 67890 628537 ... 49964 368868 utm_campaign=>’social’ ...
  5. 5. app_id user_id properties HSTORE events HSTORE[] 12345 102756 email=>’coolguy@mail.com’, ab_test_grp=>’A’ ... 12345 300732 ab_test_grp=>’B’ ... 67890 628537 ... 49964 368868 utm_campaign=>’social’ ... app_id user_i d properties HSTORE events HSTORE[] 75632 257186 ... ... 75632 120554 ... ... app_id user_i d properties HSTORE events HSTORE[] … … users_001 users_002 users
  6. 6. app_id user_id properties HSTORE events HSTORE[] 12345 102756 email=>’coolguy@mail.com’, ab_test_grp=>’A’ ... 12345 300732 ab_test_grp=>’B’ ... 67890 628537 ... 49964 368868 utm_campaign=>’social’ ... … … users_001 users_002 users app_id user_i d properties HSTORE events HSTORE[] 75632 257186 ... ... 75632 120554 ... ... SELECT COUNT(*) FROM users WHERE app_id = 12345 GROUP BY events[1]->'path'
  7. 7. users_001 users SELECT COUNT(*) FROM users WHERE app_id = 12345 GROUP BY events[1]->'path' SELECT COUNT(*) FROM users_001 WHERE app_id = 12345 GROUP BY events[1]->'path'
  8. 8. ● Denormalized → fast, no joins. ● Subqueries are just postgres. ● Add UDFs for more expressiveness.
  9. 9. funnel_events(events hstore[], pattern_array text[]) RETURNS int[] -- Returns an array with 1s corresponding to steps completed -- in the funnel, 0s in the other positions
  10. 10. funnel_events(events hstore[], pattern_array text[]) RETURNS int[] -- Returns an array with 1s corresponding to steps completed -- in the funnel, 0s in the other positions SELECT sum( funnel_events( events, ARRAY['"path"=>"/","object"=>"pageview"', '"type"=>"submit","hierarchy"=>like "%@form;#signup;%"'] ) ) AS "funnel_results" FROM users WHERE app_id = 12345
  11. 11. ● Denormalized schema. (No joins.) ● CitusDB to distribute queries. ● Express any analysis with UDFs.
  12. 12. Questions?

×