path.inc query should run faster on InnoDB

David Strauss - May 19, 2008 - 22:10
Project:Drupal
Version:6.x-dev
Component:base system
Category:bug report
Priority:normal
Assigned:David Strauss
Status:patch (code needs review)
Description

The COUNT query in path.inc runs fine on MyISAM because MyISAM keeps track of the total rows in each table. InnoDB must count all rows.

Fortunately, we don't need to count all of them. We just need to know if there's at least one.

AttachmentSize
better_path_count.patch476 bytes

#1

webchick - May 19, 2008 - 22:14
Status:active» patch (code needs review)

#2

David Strauss - May 19, 2008 - 22:15
Status:patch (code needs review)» active

Here's a D6 version.

AttachmentSize
better_path_count_6.patch476 bytes

#3

David Strauss - May 19, 2008 - 22:17

Just checked, this is "fixed" in Drupal 7 by virtue of not running such a check at all.

#4

David Strauss - May 19, 2008 - 22:20
Status:active» patch (code needs review)

Whoops, my later comment overwrote webchick's status change.

#5

David Strauss - May 22, 2008 - 20:15

Updated patches.

AttachmentSize
better_path_count_6.patch481 bytes
better_path_count_5.patch481 bytes

#6

David Strauss - May 27, 2008 - 21:35

Account for possibility of "" and "0" as paths.

AttachmentSize
better_path_count_6.patch493 bytes
better_path_count_5.patch493 bytes

#7

drumm - June 9, 2008 - 05:15
Version:5.7» 6.x-dev
Status:patch (code needs review)» patch (code needs work)

$count is no longer an accurate name for the variable. I would rename it to $has_paths with a boolean value. The ternary operator and '> 0' can be removed.

#8

David Strauss - June 24, 2008 - 21:33
Status:patch (code needs work)» patch (code needs review)

Updated patches to include drumm's suggestions.

AttachmentSize
better_path_count_6.patch1.19 KB
better_path_count_5.patch1.01 KB

#9

David Strauss - June 24, 2008 - 22:00

Ignore those last patches. I need to handle a regression in "0" and "" path handling.

#10

drumm - June 24, 2008 - 22:19

I meant keep the !== FALSE, but remove the redundant ternary.

#11

David Strauss - June 27, 2008 - 01:44

@drumm Yes, I realized that. That's why I said my last post was bad.

 
 

Drupal is a registered trademark of Dries Buytaert.