Chris@0: storage->getDataTable()) { Chris@17: $schema[$data_table]['indexes'] += [ Chris@17: 'taxonomy_term__tree' => ['vid', 'weight', 'name'], Chris@17: 'taxonomy_term__vid_name' => ['vid', 'name'], Chris@17: ]; Chris@17: } Chris@0: Chris@0: $schema['taxonomy_index'] = [ Chris@0: 'description' => 'Maintains denormalized information about node/term relationships.', Chris@0: 'fields' => [ Chris@0: 'nid' => [ Chris@0: 'description' => 'The {node}.nid this record tracks.', Chris@0: 'type' => 'int', Chris@0: 'unsigned' => TRUE, Chris@0: 'not null' => TRUE, Chris@0: 'default' => 0, Chris@0: ], Chris@0: 'tid' => [ Chris@0: 'description' => 'The term ID.', Chris@0: 'type' => 'int', Chris@0: 'unsigned' => TRUE, Chris@0: 'not null' => TRUE, Chris@0: 'default' => 0, Chris@0: ], Chris@0: 'status' => [ Chris@0: 'description' => 'Boolean indicating whether the node is published (visible to non-administrators).', Chris@0: 'type' => 'int', Chris@0: 'not null' => TRUE, Chris@0: 'default' => 1, Chris@0: ], Chris@0: 'sticky' => [ Chris@0: 'description' => 'Boolean indicating whether the node is sticky.', Chris@0: 'type' => 'int', Chris@0: 'not null' => FALSE, Chris@0: 'default' => 0, Chris@0: 'size' => 'tiny', Chris@0: ], Chris@0: 'created' => [ Chris@0: 'description' => 'The Unix timestamp when the node was created.', Chris@0: 'type' => 'int', Chris@0: 'not null' => TRUE, Chris@0: 'default' => 0, Chris@0: ], Chris@0: ], Chris@0: 'primary key' => ['nid', 'tid'], Chris@0: 'indexes' => [ Chris@0: 'term_node' => ['tid', 'status', 'sticky', 'created'], Chris@0: ], Chris@0: 'foreign keys' => [ Chris@0: 'tracked_node' => [ Chris@0: 'table' => 'node', Chris@0: 'columns' => ['nid' => 'nid'], Chris@0: ], Chris@0: 'term' => [ Chris@0: 'table' => 'taxonomy_term_data', Chris@0: 'columns' => ['tid' => 'tid'], Chris@0: ], Chris@0: ], Chris@0: ]; Chris@0: Chris@0: return $schema; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: protected function getSharedTableFieldSchema(FieldStorageDefinitionInterface $storage_definition, $table_name, array $column_mapping) { Chris@0: $schema = parent::getSharedTableFieldSchema($storage_definition, $table_name, $column_mapping); Chris@0: $field_name = $storage_definition->getName(); Chris@0: Chris@0: if ($table_name == 'taxonomy_term_field_data') { Chris@0: // Remove unneeded indexes. Chris@0: unset($schema['indexes']['taxonomy_term_field__vid__target_id']); Chris@0: unset($schema['indexes']['taxonomy_term_field__description__format']); Chris@0: Chris@0: switch ($field_name) { Chris@0: case 'weight': Chris@0: // Improves the performance of the taxonomy_term__tree index defined Chris@0: // in getEntitySchema(). Chris@0: $schema['fields'][$field_name]['not null'] = TRUE; Chris@0: break; Chris@0: Chris@0: case 'name': Chris@0: $this->addSharedTableFieldIndex($storage_definition, $schema, TRUE); Chris@0: break; Chris@0: } Chris@0: } Chris@0: Chris@0: return $schema; Chris@0: } Chris@0: Chris@18: /** Chris@18: * {@inheritdoc} Chris@18: */ Chris@18: protected function getDedicatedTableSchema(FieldStorageDefinitionInterface $storage_definition, ContentEntityTypeInterface $entity_type = NULL) { Chris@18: $dedicated_table_schema = parent::getDedicatedTableSchema($storage_definition, $entity_type); Chris@18: Chris@18: // Add an index on 'bundle', 'delta' and 'parent_target_id' columns to Chris@18: // increase the performance of the query from Chris@18: // \Drupal\taxonomy\TermStorage::getVocabularyHierarchyType(). Chris@18: if ($storage_definition->getName() === 'parent') { Chris@18: /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ Chris@18: $table_mapping = $this->storage->getTableMapping(); Chris@18: $dedicated_table_name = $table_mapping->getDedicatedDataTableName($storage_definition); Chris@18: Chris@18: unset($dedicated_table_schema[$dedicated_table_name]['indexes']['bundle']); Chris@18: $dedicated_table_schema[$dedicated_table_name]['indexes']['bundle_delta_target_id'] = [ Chris@18: 'bundle', Chris@18: 'delta', Chris@18: $table_mapping->getFieldColumnName($storage_definition, 'target_id'), Chris@18: ]; Chris@18: } Chris@18: Chris@18: return $dedicated_table_schema; Chris@18: } Chris@18: Chris@0: }