As mentioned in #889610: List pages to be default views comment 19, there are no indexes for storm tables, which slows down a lot of queries, when they are joining other tables with the given nid.
Because of the possibilities of views relationships, we should add indexes for all nid fields.

Comments

kfritsche’s picture

Status: Active » Needs review
StatusFileSize
new10 KB

Following patch adds indexes for all nid fields.

I'm also thinking to add status/category/priority as indexes, as these are varchars and i think are often used as filter.

kfritsche’s picture

What also worth to be checked, if we are using on every join the nid and the vid or only one of them.
If we only do a JOIN stormproject stp ON (x.projectnid = stp.nid) insted of JOIN stormproject stp ON (x.projectnid = stp.nid AND x.projectvid = stp.vid), we should change the primary key to only nid and add vid as unique key, like the node table does it.

    'unique keys' => array(
      'vid'     => array('vid')
      ),
    'primary key' => array('nid'),
juliangb’s picture

We generally join on vid, as this allows revisions to work correctly.

Status: Needs review » Needs work

The last submitted patch, storm_indexes-1396238-1.patch, failed testing.

juliangb’s picture

Just one thing I saw:

+++ b/stormattribute/stormattribute.install
@@ -995,3 +998,9 @@ function stormattribute_update_6112() {
+function stormattribute_update_6201() {
+  $return = array();
+  db_add_index($ret, 'stormattribute', 'domain', array('domain'));
+  return $return;
+}

$return / $ret mismatch.

Powered by Dreditor.

kfritsche’s picture

Status: Needs work » Needs review

If storm is using only vid in the joins, we should split the primary key! The current implementation only uses the index, if we do a join with nid AND vid. Thats why this is split in the node table as well.

I will do this in the next patch, and fix the error with the $ret/$return and remove assigned_nid from timetracking, as this column doesn't exists in stormtimetracking...

kfritsche’s picture

StatusFileSize
new15.56 KB

New Patch with the fixes mentioned in #6.

juliangb’s picture

Status: Needs review » Needs work

One question that I have - surely by only having nid in each primary key now, we will have primary key violations whenever node revisions are turned on?

And one comment from reading through the code:

+++ b/storminvoice/storminvoice.install
@@ -42,6 +42,10 @@ function storminvoice_schema() {
     'primary key' => array('vid', 'nid'),

No change here, despite the key being split in update storminvoice 6201.

kfritsche’s picture

Uh. You are right. I forgot the node table only stores the current vid.
So vid should be the primary key and nid only a index or we keep the current primary key and add an extra index for vid and an index for nid. The second way sounds a little bit obscure to me, so i would prefere vid as primary key, as this is always unique and keep the nid as an index for all cases.

We should probably check the revisioning with views too.

juliangb’s picture

Yes, I'd agree with vid as primary key and nid as index.

As far as I'm aware, all views fields are set up to join on vid too.

kfritsche’s picture

Status: Needs work » Needs review
StatusFileSize
new14.98 KB

Views only uses vid. I only want to be sure.

Changed the PK to vid and all nid's as index. Its now like the node_revision table.

Want we leave it by that or do we want to add more indexes for status/category/priority, because i would be a often used filter and these are var_chars. Whats your opinion on that?
I'm not quite sure how we should handle that. It would do a minimal speed up for the query on the other hand its more overhead, which is maybe only in my case relevant.
At the moment I think at least status, datebegin, dateend will make it into storm_contrib, if we decide to not include this in storm. Because storm_contrib uses this fields in some complex queries and are boosted by the index.

juliangb’s picture

Looks good from a read through (haven't tested yet).

I'm neutral on the indexes for status/category/priority - it will always help some / hinder others.

juliangb’s picture

Status: Needs review » Reviewed & tested by the community

I've applied the patch and tested. All seems good so far.

juliangb’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.