drupal meets postgresql for drupalcamp msk 2014
DESCRIPTION
Kate Marshalkina for Moscow DrupalCamp, 28/11/14.TRANSCRIPT
![Page 2: Drupal meets PostgreSQL for DrupalCamp MSK 2014](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/2.jpg)
PostgreSQLПост-Грес-Кью-Эль или просто Постгрес
![Page 3: Drupal meets PostgreSQL for DrupalCamp MSK 2014](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/3.jpg)
• 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](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/4.jpg)
• 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](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/5.jpg)
> 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
* According to Drupal.org. 5 years 27 weeks according to Drupal.ru.
![Page 6: Drupal meets PostgreSQL for DrupalCamp MSK 2014](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/6.jpg)
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](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/7.jpg)
Who uses PostgreSQL
![Page 8: Drupal meets PostgreSQL for DrupalCamp MSK 2014](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/8.jpg)
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](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/9.jpg)
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](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/10.jpg)
PostgreSQL Feature Matrixhttp://www.postgresql.org/about/featurematrix/
![Page 11: Drupal meets PostgreSQL for DrupalCamp MSK 2014](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/11.jpg)
Latest stable: 9.39.4 RC1 released
![Page 12: Drupal meets PostgreSQL for DrupalCamp MSK 2014](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/12.jpg)
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](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/13.jpg)
PostgreSQL grows fasthttp://momjian.us/main/blogs/pgblog/2014.html#November_11_2014
![Page 14: Drupal meets PostgreSQL for DrupalCamp MSK 2014](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/14.jpg)
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](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/15.jpg)
![Page 16: Drupal meets PostgreSQL for DrupalCamp MSK 2014](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/16.jpg)
CLI: psql
UI: pgAdmin, phppgadmin
Manage PostgreSQL
![Page 17: Drupal meets PostgreSQL for DrupalCamp MSK 2014](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/17.jpg)
First time vocabulary
• User postgres
sudo -u postgres psql
• Templates for databases
• Schema
• Autovacuum
• ~/.pgpass
![Page 18: Drupal meets PostgreSQL for DrupalCamp MSK 2014](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/18.jpg)
![Page 19: Drupal meets PostgreSQL for DrupalCamp MSK 2014](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/19.jpg)
SA-CORE-2014-005
![Page 20: Drupal meets PostgreSQL for DrupalCamp MSK 2014](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/20.jpg)
Database abstraction layerstandard, vendor-agnostic abstraction layer for accessing database servers
![Page 21: Drupal meets PostgreSQL for DrupalCamp MSK 2014](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/21.jpg)
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](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/22.jpg)
Database API & EFQ works with any DB
![Page 23: Drupal meets PostgreSQL for DrupalCamp MSK 2014](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/23.jpg)
PostgreSQL driver problems
1. MySQL
![Page 24: Drupal meets PostgreSQL for DrupalCamp MSK 2014](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/24.jpg)
![Page 25: Drupal meets PostgreSQL for DrupalCamp MSK 2014](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/25.jpg)
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](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/26.jpg)
So, what’s next for you?
![Page 27: Drupal meets PostgreSQL for DrupalCamp MSK 2014](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/27.jpg)
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](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/28.jpg)
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](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/29.jpg)
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](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/30.jpg)
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](https://reader030.vdocuments.site/reader030/viewer/2022020123/55981d671a28ab36048b4831/html5/thumbnails/31.jpg)
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/