Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291783

Slow query in NodeRevisionAccessCheck

$
0
0

Problem/Motivation

The access check looks if the node has more than one revisions, the query that it executes for that is not indexed:

mysql> select count(*) from node_revision;
+----------+
| count(*) |
+----------+
|   172996 |
+----------+

mysql> SELECT sql_no_cache COUNT(*) FROM node_field_revision WHERE nid = N AND default_langcode = 1;
+----------+
| COUNT(*) |
+----------+
|        1 |
+----------+
1 row in set (0.14 sec)

mysql> explain SELECT COUNT(*) FROM node_field_revision WHERE nid = N AND default_langcode = 1;
+----+-------------+---------------------+------+-----------------------+-----------------------+---------+-------+-------+-------------+
| id | select_type | table               | type | possible_keys         | key                   | key_len | ref   | rows  | Extra       |
+----+-------------+---------------------+------+-----------------------+-----------------------+---------+-------+-------+-------------+
|  1 | SIMPLE      | node_field_revision | ref  | node_default_langcode | node_default_langcode | 4       | const | 86881 | Using where |

Proposed resolution

extend the node_default_langcode index to include NID?

mysql> SELECT sql_no_cache COUNT(*) FROM node_field_revision WHERE nid = N AND default_langcode = 1;
+----------+
| COUNT(*) |
+----------+
|        1 |
+----------+
1 row in set (0.00 sec)

mysql> explain SELECT COUNT(*) FROM node_field_revision WHERE nid = N AND default_langcode = 1;
+----+-------------+---------------------+------+-----------------------+-----------------------+---------+-------------+------+-------------+
| id | select_type | table               | type | possible_keys         | key                   | key_len | ref         | rows | Extra       |
+----+-------------+---------------------+------+-----------------------+-----------------------+---------+-------------+------+-------------+
|  1 | SIMPLE      | node_field_revision | ref  | node_default_langcode | node_default_langcode | 8       | const,const |    1 | Using index |

Remaining tasks

User interface changes

API changes

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue categoryBug because of performance
Issue priorityMajor because of performance
Prioritized changesThe main goal of this issue is performance

Viewing all articles
Browse latest Browse all 291783

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>