Here's a patch to add the smart block table query from HEAD to mediawiki 1.4beta. The current implementation is painful when checking if logged in users are on the block list as the query cannot use indexes and has to scan the entire table, which is apparantly causing big pain for en.wikipedia. Please apply.
doesn't this break for mysql 3.23 ?
I mentioned this on http://bugzilla.wikipedia.org/show_bug.cgi?id=1244 already.
christof
On Thu, 03 Feb 2005, Frank v Waveren wrote:
Here's a patch to add the smart block table query from HEAD to mediawiki 1.4beta. The current implementation is painful when checking if logged in users are on the block list as the query cannot use indexes and has to scan the entire table, which is apparantly causing big pain for en.wikipedia. Please apply.
+++ includes/Block.php 2005-02-03 22:07:20.000000000 +0100 @@ -81,10 +81,17 @@ $sql = "SELECT * FROM $ipblocks WHERE ipb_user={$user} $options"; } elseif ($user=="") { $sql = "SELECT * FROM $ipblocks WHERE ipb_address='" . $db->strencode( $address ) . "' $options";
} else {
$sql = "SELECT * FROM $ipblocks WHERE (ipb_address='" . $db->strencode( $address ) .
"' OR ipb_user={$user}) $options";
}
} elseif ( $options=='' ) {
# If there are no options (e.g. FOR UPDATE), use a UNION
# so that the query can make efficient use of indices
$sql = "SELECT * FROM $ipblocks WHERE ipb_address='" . $db->strencode( $address ) .
"' UNION SELECT * FROM $ipblocks WHERE ipb_user={$user}";
} else {
# If there are options, a UNION can not be used, use one
# SELECT instead. Will do a full table scan.
$sql = "SELECT * FROM $ipblocks WHERE (ipb_address='" . $db->strencode( $address ) .
"' OR ipb_user={$user}) $options";
}
$res = $db->query( $sql, $fname ); if ( 0 == $db->numRows( $res ) ) {
Wikitech-l mailing list Wikitech-l@wikimedia.org http://mail.wikipedia.org/mailman/listinfo/wikitech-l
On Fri, Feb 04, 2005 at 09:43:17AM +0100, Christof Damian wrote:
doesn't this break for mysql 3.23 ?
I mentioned this on http://bugzilla.wikipedia.org/show_bug.cgi?id=1244 already.
Nope, check the elseif ( $options=='' ) { in front of it.
On Fri, Feb 04, 2005 at 08:15:07PM +0100, Frank v Waveren wrote:
On Fri, Feb 04, 2005 at 09:43:17AM +0100, Christof Damian wrote:
doesn't this break for mysql 3.23 ?
I mentioned this on http://bugzilla.wikipedia.org/show_bug.cgi?id=1244 already.
Nope, check the elseif ( $options=='' ) { in front of it.
Oops, read the wrong one. Yeah, I think this breaks MySQL. Hold on, let me see if I can do it without using UNION, but otherwise I think it might be worthwhile to require whatever version introduced UNION. (or have a $wgOldMysql option that falls back on slow behaviour, unless people object to having that).
Ok, how about this? It turns out the wheel has already been invented, so I'm using $wgDBmysql4. With a little code ugliness you could fix it to use separate selects on 3.x, but I'm assuming nobody runs a serious Mediawiki on MySQL 3.x anymore.
On Sat, 05 Feb 2005, Frank v Waveren wrote:
Ok, how about this? It turns out the wheel has already been invented, so I'm using $wgDBmysql4.
that looks good.
With a little code ugliness you could fix it to use separate selects on 3.x, but I'm assuming nobody runs a serious Mediawiki on MySQL 3.x anymore.
no :-) as soon as krass.com get serious I will upgrade.
cheers, christof
wikitech-l@lists.wikimedia.org