32
PostgreSQL Bye, the dolphin. Hello, the elephant. Kate Marshalkina [email protected] @kalabro

Drupal meets PostgreSQL for DrupalCamp MSK 2014

Embed Size (px)

DESCRIPTION

Kate Marshalkina for Moscow DrupalCamp, 28/11/14.

Citation preview

Page 1: Drupal meets PostgreSQL for DrupalCamp MSK 2014

PostgreSQLBye, the dolphin. Hello, the elephant.

Kate Marshalkina

[email protected]@kalabro

Page 2: Drupal meets PostgreSQL for DrupalCamp MSK 2014

PostgreSQLПост-Грес-Кью-Эль или просто Постгрес

Page 3: Drupal meets PostgreSQL for DrupalCamp MSK 2014

• PostgreSQL 100500x faster that MySQL and Oracle DB

• 200k times more reliable

• 13 times more secure

• 221 times cheaper

• ...∞

Faster, better, stronger

Page 4: Drupal meets PostgreSQL for DrupalCamp MSK 2014

• PostgreSQL 100500x faster that MySQL and Oracle DB

• 200k times more reliable

• 13 times more secure

• 221 times cheaper

• ...∞

Faster, better, stronger

???Well, I don’t know.

Page 5: Drupal meets PostgreSQL for DrupalCamp MSK 2014

> whoami

Kate Marshalkina, Senior Web Developer (not a DBA!)

6 year of PHP, 3 years 4 months * with Drupal + Postgres

https://www.drupal.org/u/kalabro and @kalabro

[email protected]

* According to Drupal.org. 5 years 27 weeks according to Drupal.ru.

Page 6: Drupal meets PostgreSQL for DrupalCamp MSK 2014

Agenda

• About PostgreSQL

• Install Drupal + PostgreSQL

• Discover why it works (Drupal DBAL)

• The most important slide #3

• Who you are in Drupal dev world and what to do with it?

• Links

Page 7: Drupal meets PostgreSQL for DrupalCamp MSK 2014

Who uses PostgreSQL

Page 8: Drupal meets PostgreSQL for DrupalCamp MSK 2014

PostgreSQL

• Object-relational

• True open source

• Follows standards (ANSI-SQL, ACID)

• MVCC

• Sophisticated query planner/optimizer

• Replication

Page 9: Drupal meets PostgreSQL for DrupalCamp MSK 2014

PostgreSQL (advanced)

• Inherited tables

• Huge amount of build-in data types + custom types

• Advanced indexes (compound, unique, partial, functional)

• Stored procedures

• Full text search (FTS)

• JSON(B)

• Extensions (hstore, PostGIS, dblink, …)http://www.postgresql.org/docs/9.3/static/contrib.html

Page 10: Drupal meets PostgreSQL for DrupalCamp MSK 2014

PostgreSQL Feature Matrixhttp://www.postgresql.org/about/featurematrix/

Page 11: Drupal meets PostgreSQL for DrupalCamp MSK 2014

Latest stable: 9.39.4 RC1 released

Page 12: Drupal meets PostgreSQL for DrupalCamp MSK 2014

JSON?

Simple Key=Value (hstore) supported since 8.3

Full JSON (jsonb) with indexes — in PostgreSQL 9.4!

Thanks to dev team:

Олег Бартунов, Александр Коротков, Федор Сигаев

Page 13: Drupal meets PostgreSQL for DrupalCamp MSK 2014

PostgreSQL grows fasthttp://momjian.us/main/blogs/pgblog/2014.html#November_11_2014

Page 14: Drupal meets PostgreSQL for DrupalCamp MSK 2014

Install PostgreSQL + Drupal

1. Install PostgresThe most difficult part: pg_hba.conf

2. Run pgtune (optionally)

3. Install php5-pgsql

4. Install Drupal

Page 15: Drupal meets PostgreSQL for DrupalCamp MSK 2014
Page 16: Drupal meets PostgreSQL for DrupalCamp MSK 2014

CLI: psql

UI: pgAdmin, phppgadmin

Manage PostgreSQL

Page 17: Drupal meets PostgreSQL for DrupalCamp MSK 2014

First time vocabulary

• User postgres

sudo -u postgres psql

• Templates for databases

• Schema

• Autovacuum

• ~/.pgpass

Page 18: Drupal meets PostgreSQL for DrupalCamp MSK 2014
Page 19: Drupal meets PostgreSQL for DrupalCamp MSK 2014

SA-CORE-2014-005

Page 20: Drupal meets PostgreSQL for DrupalCamp MSK 2014

Database abstraction layerstandard, vendor-agnostic abstraction layer for accessing database servers

Page 21: Drupal meets PostgreSQL for DrupalCamp MSK 2014

public function queryTableInformation($table) {

// Generate a key to reference this table's information on.

$key = $this->connection->prefixTables('{' . $table . '}');

if (!strpos($key, '.')) {

$key = 'public.' . $key;

}

// ….

Example: schema support in pgsql/schema.inc

Page 22: Drupal meets PostgreSQL for DrupalCamp MSK 2014

Database API & EFQ works with any DB

Page 23: Drupal meets PostgreSQL for DrupalCamp MSK 2014

PostgreSQL driver problems

1. MySQL

Page 24: Drupal meets PostgreSQL for DrupalCamp MSK 2014
Page 25: Drupal meets PostgreSQL for DrupalCamp MSK 2014

MySQL vs PostgreSQL Drupal benchmarks?

http://posulliv.github.io/2012/06/29/mysql-postgres-bench/

«Certainly, from a performance point of view, I see no issues with using PostgreSQL with Drupal. In fact, for Drupal sites using the Views module (probably the majority), I would say PostgreSQL is probably even a better option than MySQL due to its more advanced optimizer and execution engine.»

Well-tuned MySQL is often quicker in synthetic tests.

Page 26: Drupal meets PostgreSQL for DrupalCamp MSK 2014

So, what’s next for you?

Page 27: Drupal meets PostgreSQL for DrupalCamp MSK 2014

For Project Architect / Team Lead

PostgreSQL is an open source level BDMS with huge amount of features.

Consider PostgreSQL for quick start and continuous growth.

It competes proprietary giants like Oracle DB and smells like Enterprise for your business.

Page 28: Drupal meets PostgreSQL for DrupalCamp MSK 2014

For students / fellow developers

PostgreSQL is a great choice if you’ve just finished your Database course. It respects standards and has a lot of cool features for your night time.

As PostgreSQL market is full of highloadprojects and continuously grows.

Page 29: Drupal meets PostgreSQL for DrupalCamp MSK 2014

For Drupal Developers

Avoid MySQLisms.

• db_query()/addExpression()/…

• Use Database API in contribs

• Learn new staff by contributing to both Drupal and Postgres

• INSTALL IT ON DEV! It’s simple.

Page 30: Drupal meets PostgreSQL for DrupalCamp MSK 2014

For PostgreSQL DBA

• Drupal dislikes logic outside of itself.

• Optimize queries and cache.

• Integrate DB views with Drupal API.

Page 31: Drupal meets PostgreSQL for DrupalCamp MSK 2014

PostgreSQL meets Drupal

• http://planet.postgresql.org/

• http://www.meetup.com/postgresqlrussia/

• http://postgresmen.ru/articles/postgresql-users-russia-2014

• http://prodrupal.ru/ru/node/129

• https://www.drupal.org/node/555514

• http://pgconf.ru/

Page 32: Drupal meets PostgreSQL for DrupalCamp MSK 2014

sudo apt-get install postgresql

by Kate Marshalkina

[email protected]@kalabro