Introduction To Postgres. Rodrigo Menezes

Size: px
Start display at page:

Download "Introduction To Postgres. Rodrigo Menezes"

Transcription

1 Introduction To Postgres Rodrigo Menezes

2 I joined in 2013, when we were ~20 people Acquired by Oracle during summer of 2017 Currently, we re about ~250 people I started off as a frontend developer

3 This Talk Why Postgres? Brief introduction to SQL ORM (Object relational mapper) Transactions Performance and indices Views and Materialized Views JSON and Postgres Scaling Moat

4 Why PostgreSQL?

5 Why PostgreSQL? Free + open source Really good community Fast bug fixes and frequent release cycle Amazing docs "Add features slowly, do them well" Great performance Ton of cool features SQL is great and people can pry it from my cold, dead hands

6 What is SQL?

7 SQL SQL is a language for inserting, updating, reading and deleting data SQL is meant for humans (pros and cons to this) SQL is everywhere. Has been since the 70s Every collection of data is a "table" Every new datapoint is a "row"

8 Creating a table postgres=# CREATE TABLE users( id INTEGER NOT NULL, TEXT NOT NULL, name TEXT ); CREATE TABLE Time: ms

9 Inserting a row postgres=# INSERT INTO users(id, ) VALUES( 0, 'rodrigo.menezes@oracle.com' ); INSERT 0 1 Time: ms

10 Selecting a row postgres=# SELECT id, , name FROM users WHERE id=0; id name rodrigo.menezes@oracle.com (1 row)

11 Selecting all columns postgres=# SELECT * FROM users WHERE id=0; id name rodrigo.menezes@oracle.com (1 row)

12 Case insensitive postgres=# select * from users where id=0; id name rodrigo.menezes@oracle.com (1 row)

13 Updating a row postgres=# UPDATE users SET ="larry.ellison@oracle.com" WHERE id=0; UPDATE 1 Time: ms

14 Deleting a row postgres=# DELETE FROM users WHERE id=0; DELETE 1 Time: ms

15 Dropping a table postgres=# DROP TABLE users; DROP TABLE Time: ms

16 Why SQL? It's great for human beings Standards are nice In the majority of cases, you want your data strongly typed Less accidents More assumptions => more performance / compression Compile-time errors in strongly typed languages

17 ORMs (Object Relation Mapper)

18 You can write a raw query # python import psycopg2 # Library to talk to Postgres def create_cursor(): conn = psycopg2.connect("dbname=test user=postgres") cursor = conn.cursor() def update_ (cursor, id, new_ ): query= ( 'UPDATE users SET ={}' 'WHERE id = {} LIMIT 1' ).format(id) cursor.execute(query)

19 SQL Injection... def update_ (cursor, id, new_ ): query= ( 'UPDATE users SET ={}' 'WHERE id = {} LIMIT 1' ).format(id) cursor.execute(query) update_ (create_cursor(), 1, 'NULL; DROP TABLE user; --`); # `--` is a SQL comment so it ignores the rest of the line

20 ORMs Library that handles all your SQL for you Handles user input for you to make it secure Neater syntax that hides SQL complexity (which is mostly a pro but sometimes a con)

21 Sequelize // db.js import { Sequelize } from 'sequelize'; sequelize = new Sequelize({ database: POSTGRES_DB, dialect: 'postgres', host: POSTGRES_HOSTNAME, password: POSTGRES_PASSWORD, username: POSTGRES_USER, });

22 Sequelize Model // models/user.js import { Sequelize } from 'sequelize'; const User = sequelize.define('users', { id: { type: Sequelize.INTEGER, autoincrement: true, primarykey: true }, { type: Sequelize.TEXT, unique: true } });

23 Model usage // services/createuser.js import { User } from './models/user.js'; function createuser() { const user = await User.create({ }); } function getuser() { const user = await User.find({ }); }

24 Transactions and constraints

25 Let's make a Venmo clone postgres=# create table users( id serial primary key, text not null, money bigint not null default 0 );

26 Aside: serials postgres=# CREATE TABLE users( id SERIAL NOT NULL, TEXT NOT NULL ); -- Now I don't need to specify ids postgres=# INSERT INTO users( ) VALUES ( 'rodrigo.menezes@oracle.com' ); postgres=# SELECT * FROM users; id rodrigo.menezes@oracle.com (1 row)

27 Sending $20 from user 1 to user 2 # Make sure user 1 has enough money postgres=# select money from users where id = 1; # Decrease user 1's money postgres=# update users set money=money 20 where id=1; # What happens if our webserver disconnects here? # Increase user 2's money postgres=# update users set money=money + 20 where id=2;

28 Transactions postgres=# begin; postgres=# select money from users where id = 1; postgres=# update users set money=money 20 where id=1; postgres=# update users set money=money + 20 where id=2; postgres=# commit;

29 Transactions postgres=# begin; postgres=# select money from users where id = 1; postgres=# update users set money=money 20 where id=1; postgres=# abort; -- revert all changes!

30 Transactions Transactions allow the effects of your code to happen in one go Achieve ACID compliance Atomicity everything in the transaction happens or none of it does Consistency after a transaction, the database will be in a valid state. Rules always apply. Isolation a newly committed transaction shouldn't affect your current transaction (there are multiple levels of this) Durability once a transaction is committed, it'll remain so even in case of power loss.

31 Wrap everything in a transaction // wrapview.js import sequelize from './db/sequelize'; export default function wrapview(fn) { return (req, res, next) => { sequelize.transaction(t => { return fn(req, res) }).catch(next); }; } // server.ts app.post("/api/user", wrapview(users.create));

32 Race condition -- Assume user 1 has $20 postgres=# select money from users where id = 1; postgres=# select money from users where id = 1; postgres=# update users set money=money 20 where id=1; postgres=# update users set money=money 20 where id=1; # Increase user 2's money postgres=# update users set money=money + 20 where id=2; # Increase user 3's money postgres=# update users set money=money + 20 where id=2; -- Now user 1 has -$20

33 Constraints postgres=# create table users( id serial primary key, text not null, money bigint not null default 0 check (money > 0) );

34 Race condition postgres=# begin; postgres=# begin; postgres=# update users set money=money 20 where id=1; -- will error out if necessary postgres=# update users set money=money 20 where id=1; -- will error out if necessary postgres=# update users set money=money + 20 where id=2; postgres=# update users set money=money + 20 where id=3; postgres=# commit; postgres=# commit;

35 Transactions make for safe testing # python import transaction from pyramid import testing from moatpro.web import add_routes class BaseTest(object): def setup_method(self, method): self.config = testing.setup() add_routes(self.config) transaction.begin() def teardown_method(self, method): testing.teardown() transaction.abort()

36 Performance and indices

37 Let's make a lot of fake data postgres=# CREATE TABLE users( postgres-# id SERIAL, postgres-# TEXT NOT NULL postgres-#); postgres=# INSERT INTO users( ) postgres-# SELECT 'test_' id::text '@ .com' postgres-# FROM generate_series(0, ) id; INSERT Time: ms postgres=# SELECT * FROM users; id test_0@ .com 2 test_1@ .com 3 test_2@ .com...

38 How slow do things get? postgres=# select * from users where ='test_0@ .com'; id test_0@ .com (1 row) Time: ms -- Can we make this faster?

39 Explain query postgres=# explain select * from users where ='something'; QUERY PLAN Gather (cost= rows=50000 width=36) Workers Planned: 2 -> Parallel Seq Scan on users (cost= rows=20833 width=36) Filter: ( = 'test_0@ .com'::text) (4 rows)

40 Indices postgres=# CREATE INDEX on users( ); CREATE INDEX Time: ms postgres=# explain select * from users where ='test_0@ .com'; QUERY PLAN Index Scan using users_ _idx on users (cost= rows=1 width=36) Index Cond: ( = 'test_0@ .com'::text) (2 rows)

41 Indices postgres=# select * from users where ='test_0@ .com'; id test_0@ .com (1 row) Time: ms -- Went from ~1s to ~1ms! x1000 speed up!

42 Unique index postgres=# CREATE UNIQUE INDEX ON users( ); postgres=# INSERT INTO users( ) INSERT 0 1 Time: ms postgres=# INSERT INTO users( ) VALUES ('rclmenezes@gmail.com'); ERROR: duplicate key value violates unique constraint "users_ _idx" DETAIL: Key ( )=(rclmenezes@gmail.com) already exists. Time: ms

43 Unique indices... wat? postgres=# CREATE TABLE users2( id SERIAL, TEXT -- NOT NULL ); postgres=# CREATE UNIQUE INDEX ON users2( ); postgres=# INSERT INTO users2( ) VALUES (null); INSERT 0 1 Time: ms postgres=# INSERT INTO users2( ) VALUES (null); INSERT 0 1 Time: ms

44 You can do indices on multiple columns postgres=# CREATE TABLE players( postgres-# id SERIAL PRIMARY KEY, postgres-# team TEXT NOT NULL, postgres-# jersey INTEGER NOT NULL, postgres-# first_name TEXT NOT NULL, postgres-# last_name TEXT NOT NULL postgres-#); postgres=# CREATE UNIQUE INDEX ON players(team, jersey);

45 A primary key is a not-null, unique constraint with an index postgres=# \d players Table "public.players" Column Type Modifiers id integer not null default nextval('players_id_seq'::regclass) team text not null jersey integer not null first_name text not null last_name text not null Indexes: "players_pkey" PRIMARY KEY, btree (id) "players_team_jersey_idx" UNIQUE, btree (team, jersey)

46 ETL with Postgres

47 moat ad search

48 Impressions table postgres=# create table impressions( brand_id integer not null, ad_id integer not null, created_at timestamp not null default current_timestamp ); -- For a specific brandand ad, we want results like this: -- day brand_id ad_id num_impressions

49 Simple group by postgres=# create table impressions( postgres-# brand_id int not null, postgres-# ad_id int not null, postgres-# created_at timestamp not null default current_timestamp postgres-#); postgres=# postgres-# postgres-# postgres-# select created_at::date, brand_id, ad_id, count(id) from impressions group by created_at::date, brand_id, ad_id where ad_id = foo and brand = bar; -- This query is a mouthful and it'd be a pain to type out all the time.

50 View postgres=# postgres-# postgres-# postgres-# postgres-# create view ad_brand_impressions_per_day select created_at::date as day, brand_id, ad_id, count(id) from impressions group by created_at::date, brand_id, ad_id where ad_id = foo and brand = bar; postgres=# select * from num_impressions_per_day postgres-# where brand_id=?; -- What if this is slow?

51 Number of creatives per brand? -- What if you want to see the number of ads a brand had in a daterange? postgres=# select brand_id, count(distinct ad_id) postgres-# from num_impressions_per_day postgres-# where brand_id=<blah> and day between ' ' and ' ' postgres-# group by brand_id; -- What if this is slow?

52 Materialized view create materialized view impressions_by_day as select created_at::date as day, brand_id, ad_id, count(id) as num_impressions from impressions group by created_at::date, hostname_id, ad_id; create unique index on impressions_by_day(day, brand_id, ad_id); select * from impressions_by_day where brand_id=foo and ad_id=bar;

53 Materialized view # Your ETL is now: refresh materialized view impressions_by_day; # But refreshes block reads, so if you have a unique index, # you can do: refresh materialized view impressions_by_day concurrently;

54 JSON and Postgres

55 latency analytics

56 Things to consider Our data is coming in via JSON because it's coming from a browser We don't know how our JSON schema will change We're going to have a lot of columns In this case, maybe it's fine to use JSON column type

57 JSON postgres=# create table ad_analysis( id serial primary key, analysis json not null, created_at timestamp not null default current_timestamp, updated_at timestamp not null default current_timestamp ); postgres=# insert into ad_analysis(analysis) values('{"size": 1234}'::json); postgres=# select analysis->>'size' from ad_analysis;?column? (1 row)

58 Normal JSON type isn't great postgres=# SELECT '{"c":0, json {"c":0, "a":2,"a":1} (1 row) postgres=# SELECT '{"c":0,?column? (1 row) "a":2,"a":1}'::json; "a":2,"a":1}'::json->>'a'; postgres=# create index on ad_analysis(analysis); ERROR: data type json has no default operator class for access method "btree"

59 Use JSONB postgres=# SELECT '{"c":0, "a":2,"a":1}'::jsonb; jsonb {"a": 1, "c": 0} (1 row) Time: ms postgres=# create index on ad_analysis(analysis); CREATE INDEX Time: ms -- Really good performance!

60 Scaling Moat

61 moat analytics

62 What we do Measure attention online Don't track cookies/ip addresses We're a neutral third party that publishers and advertisers use We process billions of events a day

63 lots of data

64 Databases Elmo: Last 33 Days Marjory: A few years Frackles: All of our historical data Decanter: aggregates our data

65 decanter

66 Foreign Data Wrapper create server other_db foreign data wrapper postgres_fdw options ( host 'other_db.moat.co', port '5432', dbname 'other_db' ); create user mapping for public server other_db options ( user 'user', password 'password' ); create schema foo; import foreign schema foo from server search_rds into foo; # works like a normal table select * from foo.table;

67 Foreign Data Wrappers Great way to talk to other databases Can talk to other types of data stores too (there's a mysql_fdw, elasticsearch_fdw, etc). Careful the query planner can be dumb. You can put the results in an mview if you want.

68 Decanter PostgreSQL instance that doesn't store data High CPU, high memory, no storage Gets results from the other databases via FDW and aggregates them Highly available (pgbouncer) If the databases down there change, the client doesn't notice

69 marjory

70 Our data considerations We have a lot of data We're basically bean-counters ("how many times did X happen?". So, we basically need to filter and sum. The rows are very wide and very sparse (a lot of NULLs). This makes columnar solutions not work well This is very compressable

71

72

73

74

75 Marjory 8-10x compression for our data CPU bound instead of IO bound Pretty great performance We use it for some historical data (a few years) Inflexible: we're trading generality for fit to our use case Probably not great if there's a lot of rows

76 frackles

77 Frackles Access ALL our historical data Needs to be cheap Support a lot of concurrency Be able to spin up new instances fast for scale Bonus: be faster than RedShift

78 What if Our database was just a series of SQLite files in S3 We used AWS Lambda to pull those S3 files and read from them We used a Python client to manage all of those lambdas and gave it a simple API We wrote our own FDW to talk to the Python client (I was really skeptical)

79

80 Frackles Surprisingly good performance It's dirt cheap you only pay for S3 and Lambdas Completely stateless (almost no ops!) Constant overhead S3 performance has high variance Capped on number of concurrent lambdas Better on queries with little aggregation

81

82 In summary

83 We re hiring. A lot. rodrigo.menezes@oracle.com

Cloud Architecture Patterns. Running PostgreSQL at Scale (when RDS will not do what you need) Corey Huinker Corlogic Consulting December 2018

Cloud Architecture Patterns. Running PostgreSQL at Scale (when RDS will not do what you need) Corey Huinker Corlogic Consulting December 2018 Cloud Architecture Patterns Running PostgreSQL at Scale (when RDS will not do what you need) Corey Huinker Corlogic Consulting December 2018 First, we need a problem to solve. This is You You Get An Idea

More information

Postgres Copy Table From One Schema To Another

Postgres Copy Table From One Schema To Another Postgres Copy Table From One Schema To Another PostgreSQL: how to periodically copy many tables from one database to another but am free to export a copy of both to another server and do whatever I want

More information

The power of PostgreSQL exposed with automatically generated API endpoints. Sylvain Verly Coderbunker 2016Postgres 中国用户大会 Postgres Conference China 20

The power of PostgreSQL exposed with automatically generated API endpoints. Sylvain Verly Coderbunker 2016Postgres 中国用户大会 Postgres Conference China 20 The power of PostgreSQL exposed with automatically generated API endpoints. Sylvain Verly Coderbunker Development actors Frontend developer Backend developer Database administrator System administrator

More information

New and cool in PostgreSQL

New and cool in PostgreSQL New and cool in PostgreSQL ConFoo 2016 Montreal, Canada Magnus Hagander magnus@hagander.net Magnus Hagander Redpill Linpro Infrastructure services Principal database consultant PostgreSQL Core Team member

More information

YeSQL: Battling the NoSQL Hype Cycle with Postgres

YeSQL: Battling the NoSQL Hype Cycle with Postgres YeSQL: Battling the NoSQL Hype Cycle with Postgres BRUCE MOMJIAN This talk explores how new NoSQL technologies are unique, and how existing relational database systems like Postgres are adapting to handle

More information

SQL, Scaling, and What s Unique About PostgreSQL

SQL, Scaling, and What s Unique About PostgreSQL SQL, Scaling, and What s Unique About PostgreSQL Ozgun Erdogan Citus Data XLDB May 2018 Punch Line 1. What is unique about PostgreSQL? The extension APIs 2. PostgreSQL extensions are a game changer for

More information

Transactions for web developers

Transactions for web developers Transactions for web developers Aymeric Augustin - @aymericaugustin DjangoCon Europe - May 17th, 2013 1 Transaction management tools are often made to seem like a black art. Christophe Pettus (2011) Life

More information

CSE 530A ACID. Washington University Fall 2013

CSE 530A ACID. Washington University Fall 2013 CSE 530A ACID Washington University Fall 2013 Concurrency Enterprise-scale DBMSs are designed to host multiple databases and handle multiple concurrent connections Transactions are designed to enable Data

More information

Issues related to PL/pgSQL usage

Issues related to PL/pgSQL usage Issues related to PL/pgSQL usage Pavel Stěhule 2018-04-30 1 Next SQL execution Query optim. (reduced by plan cache) Query initialization (every time) Query execution (every time) Previous 2 Next Compilation

More information

DATABASE SYSTEMS. Database programming in a web environment. Database System Course,

DATABASE SYSTEMS. Database programming in a web environment. Database System Course, DATABASE SYSTEMS Database programming in a web environment Database System Course, 2016-2017 AGENDA FOR TODAY The final project Advanced Mysql Database programming Recap: DB servers in the web Web programming

More information

Chapter 8: Working With Databases & Tables

Chapter 8: Working With Databases & Tables Chapter 8: Working With Databases & Tables o Working with Databases & Tables DDL Component of SQL Databases CREATE DATABASE class; o Represented as directories in MySQL s data storage area o Can t have

More information

DATABASE SYSTEMS. Database programming in a web environment. Database System Course, 2016

DATABASE SYSTEMS. Database programming in a web environment. Database System Course, 2016 DATABASE SYSTEMS Database programming in a web environment Database System Course, 2016 AGENDA FOR TODAY Advanced Mysql More than just SELECT Creating tables MySQL optimizations: Storage engines, indexing.

More information

Topics. History. Architecture. MongoDB, Mongoose - RDBMS - SQL. - NoSQL

Topics. History. Architecture. MongoDB, Mongoose - RDBMS - SQL. - NoSQL Databases Topics History - RDBMS - SQL Architecture - SQL - NoSQL MongoDB, Mongoose Persistent Data Storage What features do we want in a persistent data storage system? We have been using text files to

More information

L6 Application Programming. Thibault Sellam Fall 2018

L6 Application Programming. Thibault Sellam Fall 2018 L6 Application Programming Thibault Sellam Fall 2018 Topics Interfacing with applications Database APIs (DBAPIS) Cursors SQL!= Programming Language Not a general purpose programming language Tailored for

More information

Database infrastructure for electronic structure calculations

Database infrastructure for electronic structure calculations Database infrastructure for electronic structure calculations Fawzi Mohamed fawzi.mohamed@fhi-berlin.mpg.de 22.7.2015 Why should you be interested in databases? Can you find a calculation that you did

More information

Major Features: Postgres 10

Major Features: Postgres 10 Major Features: Postgres 10 BRUCE MOMJIAN POSTGRESQL is an open-source, full-featured relational database. This presentation gives an overview of the Postgres 10 release. Creative Commons Attribution License

More information

Top 20 Data Quality Solutions for Data Science

Top 20 Data Quality Solutions for Data Science Top 20 Data Quality Solutions for Data Science Data Science & Business Analytics Meetup Boulder, CO 2014-12-03 Ken Farmer DQ Problems for Data Science Loom Large & Frequently 4000000 Strikingly visible

More information

PostgreSQL Performance The basics

PostgreSQL Performance The basics PostgreSQL Performance The basics Joshua D. Drake jd@commandprompt.com Command Prompt, Inc. United States PostgreSQL Software in the Public Interest The dumb simple RAID 1 or 10 (RAID 5 is for chumps)

More information

Exploring PostgreSQL Datatypes

Exploring PostgreSQL Datatypes Exploring PostgreSQL Datatypes OpenSource Days 2013 Copenhagen, Denmark Magnus Hagander magnus@hagander.net PRODUCTS CONSULTING APPLICATION MANAGEMENT IT OPERATIONS SUPPORT TRAINING Magnus Hagander PostgreSQL

More information

PostgreSQL. JSON Roadmap. Oleg Bartunov Postgres Professional. March 17, 2017, Moscow

PostgreSQL. JSON Roadmap. Oleg Bartunov Postgres Professional. March 17, 2017, Moscow PostgreSQL JSON Roadmap Oleg Bartunov Postgres Professional March 17, 2017, Moscow NoSQL Postgres briefly 2003 hstore 2006 hstore as illustration of GIN 2012 (sep) JSON in 9.2 2012 (dec) nested hstore

More information

Announcements. SQL: Part IV. Transactions. Summary of SQL features covered so far. Fine prints. SQL transactions. Reading assignments for this week

Announcements. SQL: Part IV. Transactions. Summary of SQL features covered so far. Fine prints. SQL transactions. Reading assignments for this week Announcements 2 SQL: Part IV CPS 216 Advanced Database Systems Reading assignments for this week A Critique of ANSI SQL Isolation Levels, by Berenson et al. in SIGMOD 1995 Weaving Relations for Cache Performance,

More information

Mysql Insert Manual Timestamp Into Datetime Field

Mysql Insert Manual Timestamp Into Datetime Field Mysql Insert Manual Timestamp Into Datetime Field You can set the default value of a DATE, DATETIME or TIMESTAMP field to the For INSERT IGNORE and UPDATE IGNORE, '0000-00-00' is permitted and NULL DEFAULT

More information

Next-Generation Parallel Query

Next-Generation Parallel Query Next-Generation Parallel Query Robert Haas & Rafia Sabih 2013 EDB All rights reserved. 1 Overview v10 Improvements TPC-H Results TPC-H Analysis Thoughts for the Future 2017 EDB All rights reserved. 2 Parallel

More information

Instructor: Craig Duckett. Lecture 03: Tuesday, April 3, 2018 SQL Sorting, Aggregates and Joining Tables

Instructor: Craig Duckett. Lecture 03: Tuesday, April 3, 2018 SQL Sorting, Aggregates and Joining Tables Instructor: Craig Duckett Lecture 03: Tuesday, April 3, 2018 SQL Sorting, Aggregates and Joining Tables 1 Assignment 1 is due LECTURE 5, Tuesday, April 10 th, 2018 in StudentTracker by MIDNIGHT MID-TERM

More information

The Future of Postgres Sharding

The Future of Postgres Sharding The Future of Postgres Sharding BRUCE MOMJIAN This presentation will cover the advantages of sharding and future Postgres sharding implementation requirements. Creative Commons Attribution License http://momjian.us/presentations

More information

Traffic violations revisited

Traffic violations revisited Traffic violations revisited November 9, 2017 In this lab, you will once again extract data about traffic violations from a CSV file, but this time you will use SQLite. First, download the following files

More information

Database Systems. Shan-Hung Wu CS, NTHU

Database Systems. Shan-Hung Wu CS, NTHU Database Systems Shan-Hung Wu CS, NTHU Outline Why DBMS? Data modeling SQL queries WeatherMood + DBMS Managing big data Text indexing Pagination Deployment 2 Outline Why DBMS? Data modeling SQL queries

More information

See Types of Data Supported for information about the types of files that you can import into Datameer.

See Types of Data Supported for information about the types of files that you can import into Datameer. Importing Data When you import data, you import it into a connection which is a collection of data from different sources such as various types of files and databases. See Configuring a Connection to learn

More information

PostgreSQL/Jsonb. A First Look

PostgreSQL/Jsonb. A First Look PostgreSQL/Jsonb A First Look About Me Started programming in 1981 Owner of Enoki Solutions Inc. Consulting and Software Development Running VanDev since Oct 2010 Why PostgreSQL? Open Source Feature Rich

More information

DATABASE SYSTEMS. Introduction to MySQL. Database System Course, 2016

DATABASE SYSTEMS. Introduction to MySQL. Database System Course, 2016 DATABASE SYSTEMS Introduction to MySQL Database System Course, 2016 AGENDA FOR TODAY Administration Database Architecture on the web Database history in a brief Databases today MySQL What is it How to

More information

STARCOUNTER. Technical Overview

STARCOUNTER. Technical Overview STARCOUNTER Technical Overview Summary 3 Introduction 4 Scope 5 Audience 5 Prerequisite Knowledge 5 Virtual Machine Database Management System 6 Weaver 7 Shared Memory 8 Atomicity 8 Consistency 9 Isolation

More information

GIN in 9.4 and further

GIN in 9.4 and further GIN in 9.4 and further Heikki Linnakangas, Alexander Korotkov, Oleg Bartunov May 23, 2014 Two major improvements 1. Compressed posting lists Makes GIN indexes smaller. Smaller is better. 2. When combining

More information

CSE 344 Final Review. August 16 th

CSE 344 Final Review. August 16 th CSE 344 Final Review August 16 th Final In class on Friday One sheet of notes, front and back cost formulas also provided Practice exam on web site Good luck! Primary Topics Parallel DBs parallel join

More information

DATABASES SQL INFOTEK SOLUTIONS TEAM

DATABASES SQL INFOTEK SOLUTIONS TEAM DATABASES SQL INFOTEK SOLUTIONS TEAM TRAINING@INFOTEK-SOLUTIONS.COM Databases 1. Introduction in databases 2. Relational databases (SQL databases) 3. Database management system (DBMS) 4. Database design

More information

6.830 Lecture Recovery 10/30/2017

6.830 Lecture Recovery 10/30/2017 6.830 Lecture 14 -- Recovery 10/30/2017 Have been talking about transactions Transactions -- what do they do? Awesomely powerful abstraction -- programmer can run arbitrary mixture of commands that read

More information

modern and different PostgreSQL a talk by Armin Ronacher for DUMP 2014 (Russia)

modern and different PostgreSQL a talk by Armin Ronacher for DUMP 2014 (Russia) modern and different PostgreSQL a talk by Armin '@mitsuhiko' Ronacher for DUMP 2014 (Russia) That's me. I do Computers. Currently at Fireteam / Splash Damage. We do Internet for Pointy Shooty Games. Aside

More information

postgresql postgresql in Flask in 15 or so slides 37 slides

postgresql postgresql in Flask in 15 or so slides 37 slides postgresql postgresql in Flask in 15 or so slides 37 slides but first Principle of Least Privilege A user (or process) should have the lowest level of privilege required in order to perform his/her assigned

More information

Django 1.9 and PostgreSQL

Django 1.9 and PostgreSQL Django 1.9 and PostgreSQL Christophe Pettus Django SF Meetup thebuild.com pgexperts.com So. Much. Stuff. Django 1.7 introduced native migrations. Django 1.8 introduced and 1.9 extended django.contrib.postgres,

More information

Survey of the Azure Data Landscape. Ike Ellis

Survey of the Azure Data Landscape. Ike Ellis Survey of the Azure Data Landscape Ike Ellis Wintellect Core Services Consulting Custom software application development and architecture Instructor Led Training Microsoft s #1 training vendor for over

More information

Partitioning Shines in PostgreSQL 11

Partitioning Shines in PostgreSQL 11 Partitioning Shines in PostgreSQL 11 Amit Langote, NTT OSS Center PGConf.ASIA, Tokyo Dec 11, 2018 About me Amit Langote Work at NTT OSS Center developing PostgreSQL Contributed mainly to table partitioning

More information

Database Architectures

Database Architectures Database Architectures CPS352: Database Systems Simon Miner Gordon College Last Revised: 4/15/15 Agenda Check-in Parallelism and Distributed Databases Technology Research Project Introduction to NoSQL

More information

Databases. Course October 23, 2018 Carsten Witt

Databases. Course October 23, 2018 Carsten Witt Databases Course 02807 October 23, 2018 Carsten Witt Databases Database = an organized collection of data, stored and accessed electronically (Wikipedia) Different principles for organization of data:

More information

PostgreSQL Query Optimization. Step by step techniques. Ilya Kosmodemiansky

PostgreSQL Query Optimization. Step by step techniques. Ilya Kosmodemiansky PostgreSQL Query Optimization Step by step techniques Ilya Kosmodemiansky (ik@) Agenda 2 1. What is a slow query? 2. How to chose queries to optimize? 3. What is a query plan? 4. Optimization tools 5.

More information

Apache HAWQ (incubating)

Apache HAWQ (incubating) HADOOP NATIVE SQL What is HAWQ? Apache HAWQ (incubating) Is an elastic parallel processing SQL engine that runs native in Apache Hadoop to directly access data for advanced analytics. Why HAWQ? Hadoop

More information

Accessing other data fdw, dblink, pglogical, plproxy,...

Accessing other data fdw, dblink, pglogical, plproxy,... Accessing other data fdw, dblink, pglogical, plproxy,... Hannu Krosing, Quito 2017.12.01 1 Arctic Circle 2 Who am I Coming from Estonia PostgreSQL user since about 1990 (when it was just Postgres 4.2)

More information

End o' semester clean up. A little bit of everything

End o' semester clean up. A little bit of everything End o' semester clean up A little bit of everything Database Optimization Two approaches... what do you think they are? Improve the Hardware Has been a great solution in recent decades, thanks Moore! Throwing

More information

Brief introduction of SocketPro continuous SQL-stream sending and processing system (Part 1: SQLite)

Brief introduction of SocketPro continuous SQL-stream sending and processing system (Part 1: SQLite) Brief introduction of SocketPro continuous SQL-stream sending and processing system (Part 1: SQLite) Introduction Most of client server database systems only support synchronous communication between client

More information

DISQUS. Continuous Deployment Everything. David

DISQUS. Continuous Deployment Everything. David DISQUS Continuous Deployment Everything David Cramer @zeeg Continuous Deployment Shipping new code as soon as it s ready (It s really just super awesome buildbots) Workflow Commit (master) Integration

More information

Find All Tables Containing Column With Specified Name Oracle

Find All Tables Containing Column With Specified Name Oracle Find All Tables Containing Column With Specified Name Oracle I'M TRYING to find a column called author_last_name in oracle-apex I want to find a possible duplicate of I want to show all tables that have

More information

Using a DBMS. Shan-Hung Wu & DataLab CS, NTHU

Using a DBMS. Shan-Hung Wu & DataLab CS, NTHU Using a DBMS Shan-Hung Wu & DataLab CS, NTHU DBMS Database A database is a collection of your data stored in a computer A DBMS (DataBase Management System) is a software that manages databases 2 Outline

More information

Why use a database? You can query the data (run searches) You can integrate with other business systems that use the same database You can store huge

Why use a database? You can query the data (run searches) You can integrate with other business systems that use the same database You can store huge 175 Why use a database? You can query the data (run searches) You can integrate with other business systems that use the same database You can store huge numbers of records without the risk of corruption

More information

JSON Home Improvement. Christophe Pettus PostgreSQL Experts, Inc. SCALE 14x, January 2016

JSON Home Improvement. Christophe Pettus PostgreSQL Experts, Inc. SCALE 14x, January 2016 JSON Home Improvement Christophe Pettus PostgreSQL Experts, Inc. SCALE 14x, January 2016 Greetings! Christophe Pettus CEO, PostgreSQL Experts, Inc. thebuild.com personal blog. pgexperts.com company website.

More information

Operating systems fundamentals - B07

Operating systems fundamentals - B07 Operating systems fundamentals - B07 David Kendall Northumbria University David Kendall (Northumbria University) Operating systems fundamentals - B07 1 / 33 What is SQL? Structured Query Language Used

More information

New ways to migrate from Oracle

New ways to migrate from Oracle New ways to migrate from Oracle Laurenz Albe laurenz.albe@cybertec.at Cybertec Prague PostgreSQL Developers Day 2018 The problem Database migration consists of several parts: Migration of object definitions

More information

Hacking PostgreSQL Internals to Solve Data Access Problems

Hacking PostgreSQL Internals to Solve Data Access Problems Hacking PostgreSQL Internals to Solve Data Access Problems Sadayuki Furuhashi Treasure Data, Inc. Founder & Software Architect A little about me... > Sadayuki Furuhashi > github/twitter: @frsyuki > Treasure

More information

Essential SQLAlchemy. An Overview of SQLAlchemy. Rick Copeland Author, Essential SQLAlchemy Predictix, LLC

Essential SQLAlchemy. An Overview of SQLAlchemy. Rick Copeland Author, Essential SQLAlchemy Predictix, LLC Essential SQLAlchemy An Overview of SQLAlchemy Rick Copeland Author, Essential SQLAlchemy Predictix, LLC SQLAlchemy Philosophy SQL databases behave less like object collections the more size and performance

More information

The Stack, Free Store, and Global Namespace

The Stack, Free Store, and Global Namespace Pointers This tutorial is my attempt at clarifying pointers for anyone still confused about them. Pointers are notoriously hard to grasp, so I thought I'd take a shot at explaining them. The more information

More information

MySQL 101. Designing effective schema for InnoDB. Yves Trudeau April 2015

MySQL 101. Designing effective schema for InnoDB. Yves Trudeau April 2015 MySQL 101 Designing effective schema for InnoDB Yves Trudeau April 2015 About myself : Yves Trudeau Principal architect at Percona since 2009 With MySQL then Sun, 2007 to 2009 Focus on MySQL HA and distributed

More information

pgconf.de 2018 Berlin, Germany Magnus Hagander

pgconf.de 2018 Berlin, Germany Magnus Hagander A look at the Elephants Trunk PostgreSQL 11 pgconf.de 2018 Berlin, Germany Magnus Hagander magnus@hagander.net Magnus Hagander Redpill Linpro Principal database consultant PostgreSQL Core Team member Committer

More information

PostgreSQL, Python, and Squid.

PostgreSQL, Python, and Squid. PostgreSQL, Python, and Squid. Christophe Pettus PostgreSQL Experts, Inc. thebuild.com pgexperts.com Let s Talk Squid. What is a squid, anyway? For our purposes, a squid has three attributes: length in

More information

Application development with relational and non-relational databases

Application development with relational and non-relational databases Application development with relational and non-relational databases Mario Lassnig European Organization for Nuclear Research (CERN) mario.lassnig@cern.ch About me Software Engineer Data Management for

More information

What is the Future of PostgreSQL?

What is the Future of PostgreSQL? What is the Future of PostgreSQL? Robert Haas 2013 EDB All rights reserved. 1 PostgreSQL Popularity By The Numbers Date Rating Increase vs. Prior Year % Increase January 2016 282.401 +27.913 +11% January

More information

An Adventure in Data Modeling

An Adventure in Data Modeling An Adventure in Data Modeling The Entity-Attribute-Value Data Model!! PGConf NYC! April 4, 2014 Mark Wong! mark.wong@myemma.com! Emma Email Marketing!! @emmaemailtech Who is Emma? At Emma, we're out to

More information

Rethinking JSONB June, 2015, Ottawa, Canada. Alexander Korotkov, Oleg Bartunov, Teodor Sigaev Postgres Professional

Rethinking JSONB June, 2015, Ottawa, Canada. Alexander Korotkov, Oleg Bartunov, Teodor Sigaev Postgres Professional Rethinking JSONB June, 2015, Ottawa, Canada Alexander Korotkov, Oleg Bartunov, Teodor Sigaev Postgres Professional Oleg Bartunov, Teodor Sigaev Locale support Extendability (indexing) GiST (KNN), GIN,

More information

Storage Tier. Mendel Rosenblum. CS142 Lecture Notes - Database.js

Storage Tier. Mendel Rosenblum. CS142 Lecture Notes - Database.js Storage Tier Mendel Rosenblum.js Web Application Architecture Web Browser Web Server Storage System HTTP Internet LAN 2 Web App Storage System Properties Always available - Fetch correct app data, store

More information

Major Features: Postgres 9.5

Major Features: Postgres 9.5 Major Features: Postgres 9.5 BRUCE MOMJIAN POSTGRESQL is an open-source, full-featured relational database. This presentation gives an overview of the Postgres 9.5 release. Creative Commons Attribution

More information

CMPE 131 Software Engineering. Database Introduction

CMPE 131 Software Engineering. Database Introduction Presented By Melvin Ch ng CMPE 131 Software Engineering September 14, 2017 Database Introduction Ruby on Rails ORM Agenda Database Management System (DBMS) SQL vs NoSQL Relational Database Introduction

More information

6.830 Lecture Transactions October 23, 2017

6.830 Lecture Transactions October 23, 2017 6.830 Lecture 12 -- Transactions October 23, 2017 Quiz 1 Back? Transaction Processing: Today: Transactions -- focus on concurrency control today Transactions One of the 'big ideas in computer science'

More information

CS Final Exam Review Suggestions

CS Final Exam Review Suggestions CS 325 - Final Exam Review Suggestions p. 1 last modified: 2017-12-06 CS 325 - Final Exam Review Suggestions Based on suggestions from Prof. Deb Pires from UCLA: Because of the research-supported learning

More information

Application Authorization with SET ROLE. Aurynn Shaw, Command Prompt, Inc. PGCon 2010

Application Authorization with SET ROLE. Aurynn Shaw, Command Prompt, Inc. PGCon 2010 Application Authorization with SET ROLE Aurynn Shaw, Command Prompt, Inc. PGCon 2010 Hi Hi Aurynn Shaw DBA/Lead Dev/PM/etc @ Command Prompt * Today we re talking about AuthZ in PG * Benefits, drawbacks,

More information

PostgreSQL 9.3. PGDay NYC 2013 New York City, NY. Magnus Hagander

PostgreSQL 9.3. PGDay NYC 2013 New York City, NY. Magnus Hagander PostgreSQL 9.3 PGDay NYC 2013 New York City, NY Magnus Hagander magnus@hagander.net PRODUCTS CONSULTING APPLICATION MANAGEMENT IT OPERATIONS SUPPORT TRAINING Magnus Hagander PostgreSQL Core Team member

More information

Transaction Management: Introduction (Chap. 16)

Transaction Management: Introduction (Chap. 16) Transaction Management: Introduction (Chap. 16) CS634 Class 14 Slides based on Database Management Systems 3 rd ed, Ramakrishnan and Gehrke What are Transactions? So far, we looked at individual queries;

More information

PostgreSQL to MySQL A DBA's Perspective. Patrick

PostgreSQL to MySQL A DBA's Perspective. Patrick PostgreSQL to MySQL A DBA's Perspective Patrick King @mr_mustash Yelp s Mission Connecting people with great local businesses. My Database Experience Started using Postgres 7 years ago Postgres 8.4 (released

More information

Big Data Infrastructure at Spotify

Big Data Infrastructure at Spotify Big Data Infrastructure at Spotify Wouter de Bie Team Lead Data Infrastructure September 26, 2013 2 Who am I? According to ZDNet: "The work they have done to improve the Apache Hive data warehouse system

More information

MongoDB Web Architecture

MongoDB Web Architecture MongoDB Web Architecture MongoDB MongoDB is an open-source, NoSQL database that uses a JSON-like (BSON) document-oriented model. Data is stored in collections (rather than tables). - Uses dynamic schemas

More information

cstore_fdw Columnar store for analytic workloads Hadi Moshayedi & Ben Redman

cstore_fdw Columnar store for analytic workloads Hadi Moshayedi & Ben Redman cstore_fdw Columnar store for analytic workloads Hadi Moshayedi & Ben Redman What is CitusDB? CitusDB is a scalable analytics database that extends PostgreSQL Citus shards your data and automa/cally parallelizes

More information

SQL Interview Questions

SQL Interview Questions SQL Interview Questions SQL stands for Structured Query Language. It is used as a programming language for querying Relational Database Management Systems. In this tutorial, we shall go through the basic

More information

Database Application Development

Database Application Development CS 461: Database Systems Database Application Development supplementary material: Database Management Systems Sec. 6.2, 6.3 DBUtils.java, Student.java, Registrar.java, RegistrarServlet.java, PgRegistrar.sql

More information

Reversing. Time to get with the program

Reversing. Time to get with the program Reversing Time to get with the program This guide is a brief introduction to C, Assembly Language, and Python that will be helpful for solving Reversing challenges. Writing a C Program C is one of the

More information

Utilizing Databases in Grid Engine 6.0

Utilizing Databases in Grid Engine 6.0 Utilizing Databases in Grid Engine 6.0 Joachim Gabler Software Engineer Sun Microsystems http://sun.com/grid Current status flat file spooling binary format for jobs ASCII format for other objects accounting

More information

6.830 Lecture Recovery 10/30/2017

6.830 Lecture Recovery 10/30/2017 6.830 Lecture 14 -- Recovery 10/30/2017 Have been talking about transactions Transactions -- what do they do? Awesomely powerful abstraction -- programmer can run arbitrary mixture of commands that read

More information

NCSS: Databases and SQL

NCSS: Databases and SQL NCSS: Databases and SQL Tim Dawborn Lecture 1, January, 2016 Motivation SQLite SELECT WHERE JOIN Tips 2 Outline 1 Motivation 2 SQLite 3 Searching for Data 4 Filtering Results 5 Joining multiple tables

More information

CONSTRAINTS A DEVELOPER'S SECRET WEAPON. PG Day Paris

CONSTRAINTS A DEVELOPER'S SECRET WEAPON. PG Day Paris CONSTRAINTS A DEVELOPER'S SECRET WEAPON PG Day Paris 2018-03-15 WILL LEINWEBER @LEINWEBER CITUSDATA.COM INTRO CONSTRAINTS maybe not the most exciting topic just want DB to safely store&retrieve data stern

More information

Workshop. Introducing SQL: A Foundation of Data Analytics. Robb Sombach University of Alberta Alberta School of Business

Workshop. Introducing SQL: A Foundation of Data Analytics. Robb Sombach University of Alberta Alberta School of Business Workshop Introducing SQL: A Foundation of Data Analytics Robb Sombach University of Alberta Alberta School of Business 1 Agenda Introduction Why SQL? What about Python? R? Data Analytics Relational Database

More information

DATABASE TRANSACTIONS. CS121: Relational Databases Fall 2017 Lecture 25

DATABASE TRANSACTIONS. CS121: Relational Databases Fall 2017 Lecture 25 DATABASE TRANSACTIONS CS121: Relational Databases Fall 2017 Lecture 25 Database Transactions 2 Many situations where a sequence of database operations must be treated as a single unit A combination of

More information

Distributed Architectures & Microservices. CS 475, Spring 2018 Concurrent & Distributed Systems

Distributed Architectures & Microservices. CS 475, Spring 2018 Concurrent & Distributed Systems Distributed Architectures & Microservices CS 475, Spring 2018 Concurrent & Distributed Systems GFS Architecture GFS Summary Limitations: Master is a huge bottleneck Recovery of master is slow Lots of success

More information

Partition and Conquer Large Data in PostgreSQL 10

Partition and Conquer Large Data in PostgreSQL 10 Partition and Conquer Large Data in PostgreSQL 10 Ashutosh Bapat (EnterpriseDB) Amit Langote (NTT OSS center) @PGCon2017 Copyright EnterpriseDB Corporation, 2015. All Rights Reserved. 1 Partition-wise

More information

pgloader, Your Migration Companion PostgreSQL Conference Europe, Warsaw

pgloader, Your Migration Companion PostgreSQL Conference Europe, Warsaw pgloader, Your Migration Companion PostgreSQL Conference Europe, Warsaw Dimitri Fontaine Mastering PostgreSQL October 25, 2017 Dimitri Fontaine (Mastering PostgreSQL) pgloader, Your Migration Companion

More information

Rajiv GandhiCollegeof Engineering& Technology, Kirumampakkam.Page 1 of 10

Rajiv GandhiCollegeof Engineering& Technology, Kirumampakkam.Page 1 of 10 Rajiv GandhiCollegeof Engineering& Technology, Kirumampakkam.Page 1 of 10 RAJIV GANDHI COLLEGE OF ENGINEERING & TECHNOLOGY, KIRUMAMPAKKAM-607 402 DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING QUESTION BANK

More information

Guest Lecture. Daniel Dao & Nick Buroojy

Guest Lecture. Daniel Dao & Nick Buroojy Guest Lecture Daniel Dao & Nick Buroojy OVERVIEW What is Civitas Learning What We Do Mission Statement Demo What I Do How I Use Databases Nick Buroojy WHAT IS CIVITAS LEARNING Civitas Learning Mid-sized

More information

DATABASE SYSTEMS. Introduction to MySQL. Database System Course, 2016

DATABASE SYSTEMS. Introduction to MySQL. Database System Course, 2016 DATABASE SYSTEMS Introduction to MySQL Database System Course, 2016 AGENDA FOR TODAY Administration Database Architecture on the web Database history in a brief Databases today MySQL What is it How to

More information

Rocking with Racket. Marc Burns Beatlight Inc

Rocking with Racket. Marc Burns Beatlight Inc Rocking with Racket Marc Burns Beatlight Inc What am I doing here? My first encounter with Racket was in 2010 I wanted to use Racket in industry The opportunity arose in June 2014: Loft What am I doing

More information

Chapter 9: Transactions

Chapter 9: Transactions Chapter 9: Transactions modified from: Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 9: Transactions Transaction Concept Transaction State Concurrent Executions

More information

1

1 1 2 3 6 7 8 9 10 Storage & IO Benchmarking Primer Running sysbench and preparing data Use the prepare option to generate the data. Experiments Run sysbench with different storage systems and instance

More information

SQL Data Definition Language: Create and Change the Database Ray Lockwood

SQL Data Definition Language: Create and Change the Database Ray Lockwood Introductory SQL SQL Data Definition Language: Create and Change the Database Pg 1 SQL Data Definition Language: Create and Change the Database Ray Lockwood Points: DDL statements create and alter the

More information

origin destination duration New York London 415 Shanghai Paris 760 Istanbul Tokyo 700 New York Paris 435 Moscow Paris 245 Lima New York 455

origin destination duration New York London 415 Shanghai Paris 760 Istanbul Tokyo 700 New York Paris 435 Moscow Paris 245 Lima New York 455 CS50 Beyond Databases origin destination duration New York London 415 Shanghai Paris 760 Istanbul Tokyo 700 New York Paris 435 Moscow Paris 245 Lima New York 455 SQL SQL Databases MySQL PostgreSQL SQLite...

More information

Introduction. Who wants to study databases?

Introduction. Who wants to study databases? Introduction Example databases Overview of concepts Why use database systems Who wants to study databases? What is the use of all the courses I have taken so far? This course shows very concrete how CS

More information

The EnterpriseDB Engine of PostgreSQL Development

The EnterpriseDB Engine of PostgreSQL Development The EnterpriseDB Engine of PostgreSQL The adoption of Postgres is accelerating as organizations realize new levels of operational flexibility and in recent releases. Organizations have benefited from expanding

More information

Engineering Robust Server Software

Engineering Robust Server Software Engineering Robust Server Software Scalability Other Scalability Issues Database Load Testing 2 Databases Most server applications use databases Very complex pieces of software Designed for scalability

More information

CSCI-UA: Database Design & Web Implementation. Professor Evan Sandhaus Lecture #23: SQLite

CSCI-UA: Database Design & Web Implementation. Professor Evan Sandhaus  Lecture #23: SQLite CSCI-UA:0060-02 Database Design & Web Implementation Professor Evan Sandhaus sandhaus@cs.nyu.edu evan@nytimes.com Lecture #23: SQLite Database Design and Web Implementation Administrivia! Homework HW 8

More information