MySQL5 supports compound Primary keys, and a "smart" auto_incrementer. I don't know if Postgres or other DB engines do, but this could offer a significant improvement in the database lifecycle and storage capacity of a Drupal site. It may even improve indexing.

To understand what I'm referring to, look at the "animals" demo code in: http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html

Basically, what I see in Drupal 6 and 7 in the node_revision table is this: the Revision ID is the primary key and auto_increments on its own. That's acceptable, but the key design could be improved. Because MySQL offers compound primary keys, we could set it up like such: (i'm leaving out additional fields for the sake of this example).

create table node_revision (
  nid int unsigned not null,
  vid int unsigned auto_increment not null,
  uid int unsigned not null,
  title char(255) not null default 'Untitled',
  PRIMARY KEY (nid, vid)
);

insert into node_revision (nid,uid,title) values 
(1, 1, 'My Test node'),
(1, 1, 'I renamed my Test node'),
(1, 1, 'I fixed the name of my test node'),
(2, 1, 'This is a different node'),
(2, 1, 'I renamed my different node'),
(2, 1, 'I renamed the different node again'),
(3, 1, 'Pretty, cool, huh?');

select * from node_revision;

See the vid field? It only increases when an NID&VID are already present. (And yes, I did show title as "char" instead of "varchar" because its easier for mysql to index and read than a variable width field.)

In this manner, every time a revision is created, it's not indexing from the highest revision number already in the database, its starting from the highest revision number known on that node. The advantage is that our row limit in every table with revisioning increases from 2.1bn records to (2.1*2.1)bn records.

Nodes aside, I feel this could be applied to any table that handles revisioning, and would really like to see it implemented into Drupal 8. Ideally, modules that manage revisions of their own content could do this in this manner as well.

Comments

wjaspers’s picture

Tested this in 7.x-dev.

Test Result Comments
Create Node Pass
Create Revision Pass
Revert to Revision Pass  
Create Translated Node Pass Claims it fails, but saves correctly when converting an 'und' current node to a specific language.
Batch Update Nodes SOLVED!  

16-may-2011
Strange thing -- I still can't get the title to pull up correctly. For some reason, the highest matching VID to the node NID is always the title used, but the content pulled from the field_api is correct. Not to mention all the node links generated are accurate (node/2/revision/3/view, node/5/revision/3/view).

17-may-2011:
SOLVED! I dont know how dangerous it is to modify the Entity query conditions for revisioning, but if we enforce the compound key to check both the base table entity ID and the identified revision ID, it all works out.
Changed line 260 in includes/entity.inc:
FROM:
$query->join($this->revisionTable, 'revision', "revision.{$this->revisionKey} = base.{$this->revisionKey}");
TO:
$query->join($this->revisionTable, 'revision', "revision.{$this->revisionKey} = base.{$this->revisionKey} AND revision.{$this->idKey} = base.{$this->idKey}");

Figured it all out; but I'm willing to bet the -dev code on Node I've been using is a bit out of date. Code to follow shortly.

wjaspers’s picture

StatusFileSize
new5.56 KB
new752 bytes

The only thing that doesn't seem to work properly here is that ubercart product nodes can lose track of each other because the product table indexes won't coincide with the new design--but a minor fix can resolve that.

Heres the patches, as previously mentioned:

wjaspers’s picture

Status: Active » Needs review
wjaspers’s picture

StatusFileSize
new5.44 KB
new740 bytes

Confounded WinMerge generated Win32 style line endings---AGAIN.
Lets try this once more.

Status: Needs review » Needs work

The last submitted patch, improve-node-revision-indexes-1121402.node_.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs work » Postponed (maintainer needs more info)

Wonder if this is still the case for D10?

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Following up if still a desired feature, if no follow up in 3 months will close out.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Since there's been no follow up and a feature request going to close out. Can always be re-opened

Thanks!

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.