SlideShare a Scribd company logo
1 of 25
Field Storage API
FieldableEntityStorageController
CCK

Artem Sylchuk, IntenetDevels
About me:
Drupal developer since 2010
Story 1
Save 1 000 000 nodes in 1 second
XHProf

~ 4 seconds for 50 nodes.
~ 50% of the database time.
~ 100% of the fields update time.
Anatomy of the node_save()
field_attach_presave('node', $node);
module_invoke_all('node_presave', $node);
module_invoke_all('entity_presave', $node, 'node');

drupal_write_record('node', $node);

You need all this if you want own fieldable entity.
Procedural code is simple, isn’t it?

_node_save_revision($node, $user->uid);
node_invoke($node, $op); // $op == ‘update’ || $op == ‘insert’

-------------------------------------------------------------------------------------------

// Save fields.$function = "field_attach_$op";$function('node', $node); // field_attatch_update ||
field_attach_insert
module_invoke($storage_info['module'], 'field_storage_write', …..);

field_sql_storage_field_storage_write()
Long time ago in a galaxy far away...

-------------------------------------------------------------------------------------------

module_invoke_all('node_' . $op, $node);module_invoke_all('entity_' . $op, $node, 'node');
node_access_acquire_grants($node, $delete);
entity_get_controller('node')->resetCache(array($node->nid));
Field data field & field data revision
foreach ($field['columns'] as $column => $attributes) {
$columns[] = _field_sql_storage_columnname ($field_name, $column);

}
$query = db_insert($table_name)->fields($columns);
$revision_query = db_insert($revision_name)->fields($columns);
foreach ($field_languages as $langcode) {
$items = (array) $entity->{$field_name}[$langcode];
$delta_count = 0;
foreach ($items as $delta => $item) {
// We now know we have someting to insert.

$do_insert = TRUE;

$record = array(

Function loops for all fields in the entity end performs
Delete/Insert

'entity_type' => $entity_type,
'entity_id' => $id,
'revision_id' => $vid,
'bundle' => $bundle,
'delta' => $delta,
'language' => $langcode,

);
foreach ($field['columns'] as $column => $attributes) {
$record[_field_sql_storage_columnname($field_name, $column)] = isset($item[$column]) ? $item[$column] : NULL;

}
$query->values($record);
if (isset($vid)) {
$revision_query->values($record);

}
if ($field['cardinality'] != FIELD_CARDINALITY_UNLIMITED && ++$delta_count == $field['cardinality']) {
break;

}
}

}
// Execute the query if we have values to insert.
$query->execute();
$revision_query->execute();

}
}

if ($do_insert) {
Can I haz some SQLs?
Story 2
Back in my day...
Content Construction Kit: Drupal 6
Drupal 7
Why, Dries, why?
https://drupal.org/node/1035804#comment-6860324

“This option is the one that "makes sense" to non-Drupal coders who have
written some PHP by hand before now and think they know their way
around making their own database schema. It's not wrong if you are building
one thing once..
Nowadays however, if you choose to use the Drupal framework and build reusable tools,

•
•
•

All Drupal text entity fields must be translatable (non-negotiable)
All Drupal entity fields must be revisionable (non-negotiable)
All Drupal entity fields must support being multiple (negotiable, but it's
easier to allow them to be multiple as it's free to do so)

If the problem *you* are solving today doesn't actually seem to need all those
features right now, that's quite likely. You may also know that you'll never
need to do translations, and that a number of your values aren't going to
need to be multiple (according to todays business rules anyway). Next year
you'll probably wish you'd supported revisions, but that's next year.”

© dman
«I don’t need this»

•

Field SQL Norevisions:
https://drupal.org/project/field_sql_norevisions

•

MongoDB:
https://drupal.org/project/mongodb

•

Per-Bundle Storage:
https://drupal.org/project/pbs

•

EntityFieldQuery Views Backend:
https://drupal.org/project/efq_views

•

Own storage?
Imagine
1. Storage level caching
2. Multi-update: node_save_multiple

3. Check if field was changed before
performing a query

4. Simple storage without delta and language
columns.
5. What else?
I’ll write own storage with a….
1. hook_field_storage_info().

2. hook_field_storage_details().
3. hook_field_storage_create_field().
4. hook_field_storage_update_field().
5. hook_field_storage_delete_field().

6. hook_field_storage_load().
7. hook_field_storage_write().
8. hook_entity_query_alter().
9. hook_field_storage_query().

10. hook_field_attach_rename_bundle().
11. hook_entity_insert().
12. hook_entity_update().
13. hook_field_attach_delete().
Let’s do it quick
http://posulliv.github.io/2013/01/07/bench-field-storage/

innodb_flush_log_at_trx_commit=0
innodb_doublewrite=0
log-bin=0
innodb_support_xa=0
innodb_buffer_pool_size=6G
innodb_log_file_size=512M
Curiosity is a way
forward
Drupal 8
https://drupal.org/node/1497374
extends DatabaseStorageControllerNG
which extends DatabaseStorageController
which extends FieldableEntityStorageControllerBase
which implements FieldableEntityStorageControllerInterface
FieldableEntityStorageControllerBase
What’s next?
https://drupal.org/node/2083451
Reconsider the separate field revision data tables
https://drupal.org/node/2068325
[META] Convert entity SQL queries to the Entity Query API
Questions?
Артем Сыльчук - Хранение полей в Drupal. От CCK к FieldableEntityStorageControllerInterface

More Related Content

What's hot

Microsoft HPC - Kivanc Ozuolmez - Public Content
Microsoft HPC - Kivanc Ozuolmez - Public ContentMicrosoft HPC - Kivanc Ozuolmez - Public Content
Microsoft HPC - Kivanc Ozuolmez - Public ContentKivanc Ozuolmez
 
Lightweight wrapper for Hive on Amazon EMR
Lightweight wrapper for Hive on Amazon EMRLightweight wrapper for Hive on Amazon EMR
Lightweight wrapper for Hive on Amazon EMRShinji Tanaka
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1Mohammad Qureshi
 
ECMAScript 6 and the Node Driver
ECMAScript 6 and the Node DriverECMAScript 6 and the Node Driver
ECMAScript 6 and the Node DriverMongoDB
 
Dmp hadoop getting_start
Dmp hadoop getting_startDmp hadoop getting_start
Dmp hadoop getting_startGim GyungJin
 
Joblib for cloud computing
Joblib for cloud computingJoblib for cloud computing
Joblib for cloud computingAlexandre Abadie
 
Swift after one week of coding
Swift after one week of codingSwift after one week of coding
Swift after one week of codingSwiftWro
 
Introduction to Ansible - Peter Halligan
Introduction to Ansible - Peter HalliganIntroduction to Ansible - Peter Halligan
Introduction to Ansible - Peter HalliganCorkOpenTech
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backendDavid Padbury
 
Scylla Summit 2022: ScyllaDB Embraces Wasm
Scylla Summit 2022: ScyllaDB Embraces WasmScylla Summit 2022: ScyllaDB Embraces Wasm
Scylla Summit 2022: ScyllaDB Embraces WasmScyllaDB
 
Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming  Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming Tom Croucher
 
Building your first Node app with Connect & Express
Building your first Node app with Connect & ExpressBuilding your first Node app with Connect & Express
Building your first Node app with Connect & ExpressChristian Joudrey
 
Cassandra Summit 2014: Reading Cassandra SSTables Directly for Offline Data A...
Cassandra Summit 2014: Reading Cassandra SSTables Directly for Offline Data A...Cassandra Summit 2014: Reading Cassandra SSTables Directly for Offline Data A...
Cassandra Summit 2014: Reading Cassandra SSTables Directly for Offline Data A...DataStax Academy
 
Introduction to asynchronous DB access using Node.js and MongoDB
Introduction to asynchronous DB access using Node.js and MongoDBIntroduction to asynchronous DB access using Node.js and MongoDB
Introduction to asynchronous DB access using Node.js and MongoDBAdrien Joly
 
Ansible @ WebElement 2015
Ansible @ WebElement 2015Ansible @ WebElement 2015
Ansible @ WebElement 2015Michal Maxian
 

What's hot (20)

Microsoft HPC - Kivanc Ozuolmez - Public Content
Microsoft HPC - Kivanc Ozuolmez - Public ContentMicrosoft HPC - Kivanc Ozuolmez - Public Content
Microsoft HPC - Kivanc Ozuolmez - Public Content
 
Lightweight wrapper for Hive on Amazon EMR
Lightweight wrapper for Hive on Amazon EMRLightweight wrapper for Hive on Amazon EMR
Lightweight wrapper for Hive on Amazon EMR
 
About Data::ObjectDriver
About Data::ObjectDriverAbout Data::ObjectDriver
About Data::ObjectDriver
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
ECMAScript 6 and the Node Driver
ECMAScript 6 and the Node DriverECMAScript 6 and the Node Driver
ECMAScript 6 and the Node Driver
 
Dmp hadoop getting_start
Dmp hadoop getting_startDmp hadoop getting_start
Dmp hadoop getting_start
 
Node.js
Node.jsNode.js
Node.js
 
Joblib for cloud computing
Joblib for cloud computingJoblib for cloud computing
Joblib for cloud computing
 
Swift after one week of coding
Swift after one week of codingSwift after one week of coding
Swift after one week of coding
 
Introduction to Ansible - Peter Halligan
Introduction to Ansible - Peter HalliganIntroduction to Ansible - Peter Halligan
Introduction to Ansible - Peter Halligan
 
Streams
StreamsStreams
Streams
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
Scylla Summit 2022: ScyllaDB Embraces Wasm
Scylla Summit 2022: ScyllaDB Embraces WasmScylla Summit 2022: ScyllaDB Embraces Wasm
Scylla Summit 2022: ScyllaDB Embraces Wasm
 
Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming  Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming
 
Building your first Node app with Connect & Express
Building your first Node app with Connect & ExpressBuilding your first Node app with Connect & Express
Building your first Node app with Connect & Express
 
Cassandra Summit 2014: Reading Cassandra SSTables Directly for Offline Data A...
Cassandra Summit 2014: Reading Cassandra SSTables Directly for Offline Data A...Cassandra Summit 2014: Reading Cassandra SSTables Directly for Offline Data A...
Cassandra Summit 2014: Reading Cassandra SSTables Directly for Offline Data A...
 
Introduction to asynchronous DB access using Node.js and MongoDB
Introduction to asynchronous DB access using Node.js and MongoDBIntroduction to asynchronous DB access using Node.js and MongoDB
Introduction to asynchronous DB access using Node.js and MongoDB
 
Ansible @ WebElement 2015
Ansible @ WebElement 2015Ansible @ WebElement 2015
Ansible @ WebElement 2015
 
Object Oriented Javascript
Object Oriented JavascriptObject Oriented Javascript
Object Oriented Javascript
 

Similar to Артем Сыльчук - Хранение полей в Drupal. От CCK к FieldableEntityStorageControllerInterface

Intro to drupal_7_architecture
Intro to drupal_7_architectureIntro to drupal_7_architecture
Intro to drupal_7_architectureHai Vo Hoang
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesShabir Ahmad
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practicesmanugoel2003
 
Buildingsocialanalyticstoolwithmongodb
BuildingsocialanalyticstoolwithmongodbBuildingsocialanalyticstoolwithmongodb
BuildingsocialanalyticstoolwithmongodbMongoDB APAC
 
Best Practices For Drupal Developers By Mir Nazim @ Drupal Camp India 2008
Best Practices For Drupal Developers By Mir Nazim @ Drupal Camp India 2008Best Practices For Drupal Developers By Mir Nazim @ Drupal Camp India 2008
Best Practices For Drupal Developers By Mir Nazim @ Drupal Camp India 2008Mir Nazim
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteDr Nic Williams
 
Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Angela Byron
 
Debugging Drupal - How to Debug your Drupal Application
Debugging Drupal - How to Debug your Drupal ApplicationDebugging Drupal - How to Debug your Drupal Application
Debugging Drupal - How to Debug your Drupal ApplicationZyxware Technologies
 
Open Source RAD with OpenERP 7.0
Open Source RAD with OpenERP 7.0Open Source RAD with OpenERP 7.0
Open Source RAD with OpenERP 7.0Quang Ngoc
 
Working with LoopBack Models
Working with LoopBack ModelsWorking with LoopBack Models
Working with LoopBack ModelsRaymond Feng
 
Declarative Infrastructure Tools
Declarative Infrastructure Tools Declarative Infrastructure Tools
Declarative Infrastructure Tools Yulia Shcherbachova
 
Dragoncraft Architectural Overview
Dragoncraft Architectural OverviewDragoncraft Architectural Overview
Dragoncraft Architectural Overviewjessesanford
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.jsChris Cowan
 
Gary Fowler [InfluxData] | InfluxDB Scripting Languages | InfluxDays 2022
Gary Fowler [InfluxData] | InfluxDB Scripting Languages | InfluxDays 2022Gary Fowler [InfluxData] | InfluxDB Scripting Languages | InfluxDays 2022
Gary Fowler [InfluxData] | InfluxDB Scripting Languages | InfluxDays 2022InfluxData
 
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNA
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNAFirst Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNA
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNATomas Cervenka
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS drupalcampest
 
OpenERP Technical Memento
OpenERP Technical MementoOpenERP Technical Memento
OpenERP Technical MementoOdoo
 
Open erp technical_memento_v0.6.3_a4
Open erp technical_memento_v0.6.3_a4Open erp technical_memento_v0.6.3_a4
Open erp technical_memento_v0.6.3_a4openerpwiki
 
Ebs dba con4696_pdf_4696_0001
Ebs dba con4696_pdf_4696_0001Ebs dba con4696_pdf_4696_0001
Ebs dba con4696_pdf_4696_0001jucaab
 

Similar to Артем Сыльчук - Хранение полей в Drupal. От CCK к FieldableEntityStorageControllerInterface (20)

NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 
Intro to drupal_7_architecture
Intro to drupal_7_architectureIntro to drupal_7_architecture
Intro to drupal_7_architecture
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API Changes
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 
Buildingsocialanalyticstoolwithmongodb
BuildingsocialanalyticstoolwithmongodbBuildingsocialanalyticstoolwithmongodb
Buildingsocialanalyticstoolwithmongodb
 
Best Practices For Drupal Developers By Mir Nazim @ Drupal Camp India 2008
Best Practices For Drupal Developers By Mir Nazim @ Drupal Camp India 2008Best Practices For Drupal Developers By Mir Nazim @ Drupal Camp India 2008
Best Practices For Drupal Developers By Mir Nazim @ Drupal Camp India 2008
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - Keynote
 
Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8
 
Debugging Drupal - How to Debug your Drupal Application
Debugging Drupal - How to Debug your Drupal ApplicationDebugging Drupal - How to Debug your Drupal Application
Debugging Drupal - How to Debug your Drupal Application
 
Open Source RAD with OpenERP 7.0
Open Source RAD with OpenERP 7.0Open Source RAD with OpenERP 7.0
Open Source RAD with OpenERP 7.0
 
Working with LoopBack Models
Working with LoopBack ModelsWorking with LoopBack Models
Working with LoopBack Models
 
Declarative Infrastructure Tools
Declarative Infrastructure Tools Declarative Infrastructure Tools
Declarative Infrastructure Tools
 
Dragoncraft Architectural Overview
Dragoncraft Architectural OverviewDragoncraft Architectural Overview
Dragoncraft Architectural Overview
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.js
 
Gary Fowler [InfluxData] | InfluxDB Scripting Languages | InfluxDays 2022
Gary Fowler [InfluxData] | InfluxDB Scripting Languages | InfluxDays 2022Gary Fowler [InfluxData] | InfluxDB Scripting Languages | InfluxDays 2022
Gary Fowler [InfluxData] | InfluxDB Scripting Languages | InfluxDays 2022
 
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNA
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNAFirst Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNA
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNA
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS
 
OpenERP Technical Memento
OpenERP Technical MementoOpenERP Technical Memento
OpenERP Technical Memento
 
Open erp technical_memento_v0.6.3_a4
Open erp technical_memento_v0.6.3_a4Open erp technical_memento_v0.6.3_a4
Open erp technical_memento_v0.6.3_a4
 
Ebs dba con4696_pdf_4696_0001
Ebs dba con4696_pdf_4696_0001Ebs dba con4696_pdf_4696_0001
Ebs dba con4696_pdf_4696_0001
 

More from LEDC 2016

A. Postnikov & P. Mahrinsky — Drupal Community — це ми
A. Postnikov & P. Mahrinsky — Drupal Community — це миA. Postnikov & P. Mahrinsky — Drupal Community — це ми
A. Postnikov & P. Mahrinsky — Drupal Community — це миLEDC 2016
 
Слава Мережко — Практикум: "Як ростити розробників"
Слава Мережко — Практикум: "Як ростити розробників"Слава Мережко — Практикум: "Як ростити розробників"
Слава Мережко — Практикум: "Як ростити розробників"LEDC 2016
 
Генадій Колтун — Комунізм наступає: що будемо робити, коли машини навчаться п...
Генадій Колтун — Комунізм наступає: що будемо робити, коли машини навчаться п...Генадій Колтун — Комунізм наступає: що будемо робити, коли машини навчаться п...
Генадій Колтун — Комунізм наступає: що будемо робити, коли машини навчаться п...LEDC 2016
 
Олексій Калініченко — Configuration Management in Drupal8
Олексій Калініченко — Configuration Management in Drupal8Олексій Калініченко — Configuration Management in Drupal8
Олексій Калініченко — Configuration Management in Drupal8LEDC 2016
 
Олександр Лінивий — Multisite platform with continuous delivery process for m...
Олександр Лінивий — Multisite platform with continuous delivery process for m...Олександр Лінивий — Multisite platform with continuous delivery process for m...
Олександр Лінивий — Multisite platform with continuous delivery process for m...LEDC 2016
 
Андрій Юн — Воркшоп "Docker use cases for developers"
Андрій Юн — Воркшоп "Docker use cases for developers"Андрій Юн — Воркшоп "Docker use cases for developers"
Андрій Юн — Воркшоп "Docker use cases for developers"LEDC 2016
 
Андрій Поданенко — Воркшоп "Розвертання CIBox"
Андрій Поданенко — Воркшоп "Розвертання CIBox"Андрій Поданенко — Воркшоп "Розвертання CIBox"
Андрій Поданенко — Воркшоп "Розвертання CIBox"LEDC 2016
 
Юрій Герасімов — Editorial experience in Drupal8
Юрій Герасімов — Editorial experience in Drupal8Юрій Герасімов — Editorial experience in Drupal8
Юрій Герасімов — Editorial experience in Drupal8LEDC 2016
 
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...LEDC 2016
 
Тарас Кирилюк — Docker basics. How-to for Drupal developers
Тарас Кирилюк — Docker basics. How-to for Drupal developersТарас Кирилюк — Docker basics. How-to for Drupal developers
Тарас Кирилюк — Docker basics. How-to for Drupal developersLEDC 2016
 
Тарас Круц — Open Social: brand new Drupal 8 distro for building social netwo...
Тарас Круц — Open Social: brand new Drupal 8 distro for building social netwo...Тарас Круц — Open Social: brand new Drupal 8 distro for building social netwo...
Тарас Круц — Open Social: brand new Drupal 8 distro for building social netwo...LEDC 2016
 
Ігор Карпиленко — PHPStorm for drupal developer
Ігор Карпиленко — PHPStorm for drupal developerІгор Карпиленко — PHPStorm for drupal developer
Ігор Карпиленко — PHPStorm for drupal developerLEDC 2016
 
Олександр Щедров — Build your application in seconds and optimize workflow as...
Олександр Щедров — Build your application in seconds and optimize workflow as...Олександр Щедров — Build your application in seconds and optimize workflow as...
Олександр Щедров — Build your application in seconds and optimize workflow as...LEDC 2016
 
Анатолій Поляков — Subdomains everywhere
Анатолій Поляков — Subdomains everywhereАнатолій Поляков — Subdomains everywhere
Анатолій Поляков — Subdomains everywhereLEDC 2016
 
Артем Доценко — Deploy Plus. Better UI and more control for deploy module
Артем Доценко — Deploy Plus. Better UI and more control for deploy moduleАртем Доценко — Deploy Plus. Better UI and more control for deploy module
Артем Доценко — Deploy Plus. Better UI and more control for deploy moduleLEDC 2016
 
Сергій Бондаренко — Тестування Drupal сайтiв з допогою TqExtension
Сергій Бондаренко — Тестування Drupal сайтiв з допогою TqExtensionСергій Бондаренко — Тестування Drupal сайтiв з допогою TqExtension
Сергій Бондаренко — Тестування Drupal сайтiв з допогою TqExtensionLEDC 2016
 
Вадим Абрамчук — Big Drupal: Issues We Met
Вадим Абрамчук — Big Drupal: Issues We MetВадим Абрамчук — Big Drupal: Issues We Met
Вадим Абрамчук — Big Drupal: Issues We MetLEDC 2016
 
Юрій Герасимов — Delayed operations with queues
Юрій Герасимов — Delayed operations with queuesЮрій Герасимов — Delayed operations with queues
Юрій Герасимов — Delayed operations with queuesLEDC 2016
 
Віталій Бобров — Web components, Polymer and Drupal
Віталій Бобров — Web components, Polymer and DrupalВіталій Бобров — Web components, Polymer and Drupal
Віталій Бобров — Web components, Polymer and DrupalLEDC 2016
 
Олександр Щедров та Альбіна Тюпа — Magic button. Can production releases be s...
Олександр Щедров та Альбіна Тюпа — Magic button. Can production releases be s...Олександр Щедров та Альбіна Тюпа — Magic button. Can production releases be s...
Олександр Щедров та Альбіна Тюпа — Magic button. Can production releases be s...LEDC 2016
 

More from LEDC 2016 (20)

A. Postnikov & P. Mahrinsky — Drupal Community — це ми
A. Postnikov & P. Mahrinsky — Drupal Community — це миA. Postnikov & P. Mahrinsky — Drupal Community — це ми
A. Postnikov & P. Mahrinsky — Drupal Community — це ми
 
Слава Мережко — Практикум: "Як ростити розробників"
Слава Мережко — Практикум: "Як ростити розробників"Слава Мережко — Практикум: "Як ростити розробників"
Слава Мережко — Практикум: "Як ростити розробників"
 
Генадій Колтун — Комунізм наступає: що будемо робити, коли машини навчаться п...
Генадій Колтун — Комунізм наступає: що будемо робити, коли машини навчаться п...Генадій Колтун — Комунізм наступає: що будемо робити, коли машини навчаться п...
Генадій Колтун — Комунізм наступає: що будемо робити, коли машини навчаться п...
 
Олексій Калініченко — Configuration Management in Drupal8
Олексій Калініченко — Configuration Management in Drupal8Олексій Калініченко — Configuration Management in Drupal8
Олексій Калініченко — Configuration Management in Drupal8
 
Олександр Лінивий — Multisite platform with continuous delivery process for m...
Олександр Лінивий — Multisite platform with continuous delivery process for m...Олександр Лінивий — Multisite platform with continuous delivery process for m...
Олександр Лінивий — Multisite platform with continuous delivery process for m...
 
Андрій Юн — Воркшоп "Docker use cases for developers"
Андрій Юн — Воркшоп "Docker use cases for developers"Андрій Юн — Воркшоп "Docker use cases for developers"
Андрій Юн — Воркшоп "Docker use cases for developers"
 
Андрій Поданенко — Воркшоп "Розвертання CIBox"
Андрій Поданенко — Воркшоп "Розвертання CIBox"Андрій Поданенко — Воркшоп "Розвертання CIBox"
Андрій Поданенко — Воркшоп "Розвертання CIBox"
 
Юрій Герасімов — Editorial experience in Drupal8
Юрій Герасімов — Editorial experience in Drupal8Юрій Герасімов — Editorial experience in Drupal8
Юрій Герасімов — Editorial experience in Drupal8
 
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
 
Тарас Кирилюк — Docker basics. How-to for Drupal developers
Тарас Кирилюк — Docker basics. How-to for Drupal developersТарас Кирилюк — Docker basics. How-to for Drupal developers
Тарас Кирилюк — Docker basics. How-to for Drupal developers
 
Тарас Круц — Open Social: brand new Drupal 8 distro for building social netwo...
Тарас Круц — Open Social: brand new Drupal 8 distro for building social netwo...Тарас Круц — Open Social: brand new Drupal 8 distro for building social netwo...
Тарас Круц — Open Social: brand new Drupal 8 distro for building social netwo...
 
Ігор Карпиленко — PHPStorm for drupal developer
Ігор Карпиленко — PHPStorm for drupal developerІгор Карпиленко — PHPStorm for drupal developer
Ігор Карпиленко — PHPStorm for drupal developer
 
Олександр Щедров — Build your application in seconds and optimize workflow as...
Олександр Щедров — Build your application in seconds and optimize workflow as...Олександр Щедров — Build your application in seconds and optimize workflow as...
Олександр Щедров — Build your application in seconds and optimize workflow as...
 
Анатолій Поляков — Subdomains everywhere
Анатолій Поляков — Subdomains everywhereАнатолій Поляков — Subdomains everywhere
Анатолій Поляков — Subdomains everywhere
 
Артем Доценко — Deploy Plus. Better UI and more control for deploy module
Артем Доценко — Deploy Plus. Better UI and more control for deploy moduleАртем Доценко — Deploy Plus. Better UI and more control for deploy module
Артем Доценко — Deploy Plus. Better UI and more control for deploy module
 
Сергій Бондаренко — Тестування Drupal сайтiв з допогою TqExtension
Сергій Бондаренко — Тестування Drupal сайтiв з допогою TqExtensionСергій Бондаренко — Тестування Drupal сайтiв з допогою TqExtension
Сергій Бондаренко — Тестування Drupal сайтiв з допогою TqExtension
 
Вадим Абрамчук — Big Drupal: Issues We Met
Вадим Абрамчук — Big Drupal: Issues We MetВадим Абрамчук — Big Drupal: Issues We Met
Вадим Абрамчук — Big Drupal: Issues We Met
 
Юрій Герасимов — Delayed operations with queues
Юрій Герасимов — Delayed operations with queuesЮрій Герасимов — Delayed operations with queues
Юрій Герасимов — Delayed operations with queues
 
Віталій Бобров — Web components, Polymer and Drupal
Віталій Бобров — Web components, Polymer and DrupalВіталій Бобров — Web components, Polymer and Drupal
Віталій Бобров — Web components, Polymer and Drupal
 
Олександр Щедров та Альбіна Тюпа — Magic button. Can production releases be s...
Олександр Щедров та Альбіна Тюпа — Magic button. Can production releases be s...Олександр Щедров та Альбіна Тюпа — Magic button. Can production releases be s...
Олександр Щедров та Альбіна Тюпа — Magic button. Can production releases be s...
 

Recently uploaded

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Recently uploaded (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Артем Сыльчук - Хранение полей в Drupal. От CCK к FieldableEntityStorageControllerInterface

  • 3. Story 1 Save 1 000 000 nodes in 1 second
  • 4. XHProf ~ 4 seconds for 50 nodes. ~ 50% of the database time. ~ 100% of the fields update time.
  • 5. Anatomy of the node_save() field_attach_presave('node', $node); module_invoke_all('node_presave', $node); module_invoke_all('entity_presave', $node, 'node'); drupal_write_record('node', $node); You need all this if you want own fieldable entity. Procedural code is simple, isn’t it? _node_save_revision($node, $user->uid); node_invoke($node, $op); // $op == ‘update’ || $op == ‘insert’ ------------------------------------------------------------------------------------------- // Save fields.$function = "field_attach_$op";$function('node', $node); // field_attatch_update || field_attach_insert module_invoke($storage_info['module'], 'field_storage_write', …..); field_sql_storage_field_storage_write() Long time ago in a galaxy far away... ------------------------------------------------------------------------------------------- module_invoke_all('node_' . $op, $node);module_invoke_all('entity_' . $op, $node, 'node'); node_access_acquire_grants($node, $delete); entity_get_controller('node')->resetCache(array($node->nid));
  • 6. Field data field & field data revision
  • 7. foreach ($field['columns'] as $column => $attributes) { $columns[] = _field_sql_storage_columnname ($field_name, $column); } $query = db_insert($table_name)->fields($columns); $revision_query = db_insert($revision_name)->fields($columns); foreach ($field_languages as $langcode) { $items = (array) $entity->{$field_name}[$langcode]; $delta_count = 0; foreach ($items as $delta => $item) { // We now know we have someting to insert. $do_insert = TRUE; $record = array( Function loops for all fields in the entity end performs Delete/Insert 'entity_type' => $entity_type, 'entity_id' => $id, 'revision_id' => $vid, 'bundle' => $bundle, 'delta' => $delta, 'language' => $langcode, ); foreach ($field['columns'] as $column => $attributes) { $record[_field_sql_storage_columnname($field_name, $column)] = isset($item[$column]) ? $item[$column] : NULL; } $query->values($record); if (isset($vid)) { $revision_query->values($record); } if ($field['cardinality'] != FIELD_CARDINALITY_UNLIMITED && ++$delta_count == $field['cardinality']) { break; } } } // Execute the query if we have values to insert. $query->execute(); $revision_query->execute(); } } if ($do_insert) {
  • 8. Can I haz some SQLs?
  • 9. Story 2 Back in my day...
  • 12. Why, Dries, why? https://drupal.org/node/1035804#comment-6860324 “This option is the one that "makes sense" to non-Drupal coders who have written some PHP by hand before now and think they know their way around making their own database schema. It's not wrong if you are building one thing once.. Nowadays however, if you choose to use the Drupal framework and build reusable tools, • • • All Drupal text entity fields must be translatable (non-negotiable) All Drupal entity fields must be revisionable (non-negotiable) All Drupal entity fields must support being multiple (negotiable, but it's easier to allow them to be multiple as it's free to do so) If the problem *you* are solving today doesn't actually seem to need all those features right now, that's quite likely. You may also know that you'll never need to do translations, and that a number of your values aren't going to need to be multiple (according to todays business rules anyway). Next year you'll probably wish you'd supported revisions, but that's next year.” © dman
  • 13. «I don’t need this» • Field SQL Norevisions: https://drupal.org/project/field_sql_norevisions • MongoDB: https://drupal.org/project/mongodb • Per-Bundle Storage: https://drupal.org/project/pbs • EntityFieldQuery Views Backend: https://drupal.org/project/efq_views • Own storage?
  • 14. Imagine 1. Storage level caching 2. Multi-update: node_save_multiple 3. Check if field was changed before performing a query 4. Simple storage without delta and language columns. 5. What else?
  • 15. I’ll write own storage with a…. 1. hook_field_storage_info(). 2. hook_field_storage_details(). 3. hook_field_storage_create_field(). 4. hook_field_storage_update_field(). 5. hook_field_storage_delete_field(). 6. hook_field_storage_load(). 7. hook_field_storage_write(). 8. hook_entity_query_alter(). 9. hook_field_storage_query(). 10. hook_field_attach_rename_bundle(). 11. hook_entity_insert(). 12. hook_entity_update(). 13. hook_field_attach_delete().
  • 16. Let’s do it quick http://posulliv.github.io/2013/01/07/bench-field-storage/ innodb_flush_log_at_trx_commit=0 innodb_doublewrite=0 log-bin=0 innodb_support_xa=0 innodb_buffer_pool_size=6G innodb_log_file_size=512M
  • 17. Curiosity is a way forward Drupal 8
  • 18.
  • 20. extends DatabaseStorageControllerNG which extends DatabaseStorageController which extends FieldableEntityStorageControllerBase which implements FieldableEntityStorageControllerInterface
  • 23. https://drupal.org/node/2068325 [META] Convert entity SQL queries to the Entity Query API