Missing index on url_alias table

catch - January 23, 2009 - 17:43
Project:Drupal
Version:6.x-dev
Component:path.module
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Issue tags:needs backport to D6, Performance
Description

HEAD:

#
mysql> EXPLAIN SELECT dst FROM url_alias WHERE src = 'user/1590' AND language IN('en', '') ORDER BY language DESC;
#
+----+-------------+-----------+------+---------------+------+---------+-------+------+-----------------------------+
#
| id | select_type | table     | type | possible_keys | key  | key_len | ref   | rows | Extra                       |
#
+----+-------------+-----------+------+---------------+------+---------+-------+------+-----------------------------+
#
|  1 | SIMPLE      | url_alias | ref  | src           | src  | 386     | const |    2 | Using where; Using filesort |
#
+----+-------------+-----------+------+---------------+------+---------+-------+------+-----------------------------+

With the patch:

mysql> EXPLAIN SELECT dst FROM url_alias WHERE src = 'library' AND language IN('en', '') ORDER BY language DESC;
+----+-------------+-----------+------+------------------+--------------+---------+-------+------+-------------+
| id | select_type | table     | type | possible_keys    | key          | key_len | ref   | rows | Extra       |
+----+-------------+-----------+------+------------------+--------------+---------+-------+------+-------------+
|  1 | SIMPLE      | url_alias | ref  | src,src_language | src_language | 386     | const |    1 | Using where |
+----+-------------+-----------+------+------------------+--------------+---------+-------+------+-------------+

I spotted the filesort, Damien noticed the missing index.

On my drupal 6 site, I'm getting queries upto 25ms (most around 1-2ms) in drupal_lookup_path() on a table with around 30k aliases. With the patch, everything is < 1ms.

Patch is against Drupal 7, but modifies the Drupal 6 updates - since if this goes in at all it'll need to be backported.

AttachmentSizeStatusTest resultOperations
url_alias_index.patch992 bytesIdleFailed: Failed to apply patch.View details

#1

catch - January 24, 2009 - 01:56
Priority:critical» normal

Not sure how much real difference this actually makes, so demoting from critical until I can do some proper benchmarks.

#2

Damien Tournoud - January 24, 2009 - 08:13
Status:needs review» reviewed & tested by the community

The simple (src) alias was good for D5, but should have been extended to (src, language) when D6 introduced the new language subsystem.

This can quickly become critical on a site with many aliases that change frequently.

#3

webchick - January 25, 2009 - 12:25
Status:reviewed & tested by the community» needs review

I'd like to get at least one review by someone who didn't (co-)write the patch. ;)

#4

chx - January 25, 2009 - 12:30
Status:needs review» reviewed & tested by the community

Makes a lot of sense to me...

#5

webchick - January 25, 2009 - 12:37
Status:reviewed & tested by the community» needs work

I'm pretty sure that update is going to fail, since it's missing return $ret;

#6

chx - January 25, 2009 - 12:45
Status:needs work» reviewed & tested by the community
AttachmentSizeStatusTest resultOperations
url_alias_index.patch2.86 KBIdleFailed: Failed to apply patch.View details

#7

chx - January 25, 2009 - 12:47
AttachmentSizeStatusTest resultOperations
url_alias_index.patch824 bytesIdleFailed: Failed to apply patch.View details

#8

catch - January 25, 2009 - 13:19
Status:reviewed & tested by the community» needs review

We don't have a way to check if an index exists so summary of irc discussion:

Roll this for D7 with a system_update_7*

Backport to D6 with a system_update_6*

Let Crell, chx and Damz sort out a way of checking whether the 6.x update has run or not before we release.

Here's a straight D7 patch.

AttachmentSizeStatusTest resultOperations
url_alias_index.patch1010 bytesIdleFailed: Failed to apply patch.View details

#9

webchick - January 25, 2009 - 13:58
Version:7.x-dev» 6.x-dev
Status:needs review» reviewed & tested by the community

Right. chx brought up "What happens if someone upgrades to Drupal 7 from Drupal 6.5?" the answer is, their database would get out of sync because the update would never run.

For now, I've committed #8, and left RTBC for D6 on #7. When this is committed to D6 (assuming it is), please kick back to 7.x and mark CNW so we don't forget to address this "same update might run more than once" thing in one way or the other.

#360854: db_index_exists() missing, module updates cannot handle indexes properly introduces a db_index_exists() function which is probably a good pairing with db_table_exists() and db_column_exists() to deal with this, but still needs work and review. We also desperately need to fix #363911: Batch API needs to return useful error messages.

#11

catch - January 25, 2009 - 14:42

Didn't apply properly to D6, here's a backport.

AttachmentSizeStatusTest resultOperations
url_alias_index_D6.patch1.09 KBIgnoredNoneNone

#12

Gábor Hojtsy - February 25, 2009 - 13:07
Version:6.x-dev» 7.x-dev
Status:reviewed & tested by the community» needs work

Committed to Drupal 6. Happy figuring out with the Drupal 7 upgrade path.

#13

Dave Reid - February 25, 2009 - 13:32
Status:needs work» needs review

It's easy to port this back to D7. We just rename our original update 7018 to 6049 and shift all the other 7018+ updates down one.

AttachmentSizeStatusTest resultOperations
363262-url-alias-index-D7.patch1.53 KBIdleFailed: Failed to apply patch.View details

#14

Dave Reid - February 25, 2009 - 13:35

Last patch had an extra newline.

AttachmentSizeStatusTest resultOperations
363262-url-alias-index-D7.patch1.53 KBIdleFailed: Failed to apply patch.View details

#15

Gábor Hojtsy - February 25, 2009 - 14:16
Status:needs review» needs work

Since by tradition, Drupal 7 is expected to drop all pre Drupal 6.0 update functions, it would be important to mark this as being post 6.0. System update 6047 was the last in Drupal 6.0, so the ones from there should be kept when Drupal 7 is released. A marker should be put in that place in both Drupal 6 and 7 (or previous updates should already be removed from Drupal 7).

Anyway, I think since we are moving back the updates here, this patch should add that note in.

Ref: http://cvs.drupal.org/viewvc.py/drupal/drupal/modules/system/system.inst...

#16

Dave Reid - February 25, 2009 - 14:27
Status:needs work» needs review

Gabor, I really have no idea what you're talking about. :/ We're supposed to remove any 5xxx udpates in 7.x since those are two versions behind. We should be keeping the 6xxx updates. If we simply rename the update from 7018 to 6049 in 7.x, if a user upgrades to Drupal 7 from Drupal 6.9, the update will still fire. Not sure why we need markers...

#17

Gábor Hojtsy - February 25, 2009 - 14:38
Status:needs review» needs work

Dave: well, D6 shipped with with all D5 updates minus the updates added after D 5.0 removed. See http://cvs.drupal.org/viewvc.py/drupal/drupal/modules/system/system.inst... again. It has a "@defgroup updates-5.x-extra Extra system updates for 5.x" and then starts off the 5 -> 6 upgrades. Drupal 7 is missing the updates-6.x-extra marker which will be used to cut off all update functions before it before the 7.0 release.

#18

Dave Reid - February 25, 2009 - 14:45
Status:needs work» needs review

Ah, I've got it now. Thanks Gabor. I haven't had my coffee yet so I'm not quite awake yet apparently. :)

So we are still going to need to adjust the 6.x system.install again aren't we? I'll file a new issue to remove all the 5.x to 6.x update functions.

AttachmentSizeStatusTest resultOperations
363262-url-alias-index-D7.patch1.63 KBIdleFailed: Failed to install HEAD.View details

#19

Gábor Hojtsy - February 25, 2009 - 14:52

system_update_6048() was also an extra as far as my research above found. So let's move the marker before that as I've said in #15.

#20

Dave Reid - February 25, 2009 - 15:00

Thanks again Gabor. Ok this one should be ready.

AttachmentSizeStatusTest resultOperations
363262-url-alias-index-D7.patch2.21 KBIdleFailed: Failed to apply patch.View details

#21

Dave Reid - February 25, 2009 - 15:03

Hmm... seems like I should actually move the line "The next series of updates should start at 7000." to @} End of "defgroup updates-6.x-extra". It doesn't make sense to have that line with the @} End of "defgroup updates-5.x-to-6.x"

AttachmentSizeStatusTest resultOperations
363262-url-alias-index-D7.patch2.15 KBIdleFailed: Failed to apply patch.View details

#22

System Message - April 2, 2009 - 22:20
Status:needs review» needs work

The last submitted patch failed testing.

#23

Dave Reid - April 2, 2009 - 23:46
Status:needs work» needs review

Re-rolled for the changing update functions.

AttachmentSizeStatusTest resultOperations
363262-url-alias-index-D7.patch2.32 KBIdlePassed: 10688 passes, 0 fails, 0 exceptionsView details

#24

Dries - April 3, 2009 - 17:51
Version:7.x-dev» 6.x-dev
Status:needs review» needs work

Reviewed and tested. Committed to CVS HEAD for inclusion in Drupal 7. Setting the version to Drupal 6.

#25

Dave Reid - April 3, 2009 - 18:38
Status:needs work» needs review

Revised patch for D6. The update function is already there, just adding/moving some doc blocks to show where the 5.x->6.x updates stop and the extra 6.x updates begin.

AttachmentSizeStatusTest resultOperations
363262-url-alias-index-D6.patch1.04 KBIgnoredNoneNone

#26

andypost - April 21, 2009 - 21:28

#27

Dave Reid - April 21, 2009 - 21:33
Status:needs review» reviewed & tested by the community

This is a different issue. Marking as RTBC as there is literally no code change.

#28

Gábor Hojtsy - April 27, 2009 - 12:29
Status:reviewed & tested by the community» fixed

Thanks, committed the phpdoc cleanup from #25 as well.

#29

System Message - May 11, 2009 - 12:30
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.