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(a)wikimedia.org
http://mail.wikipedia.org/mailman/listinfo/wikitech-l
--
Christof Damian
christof(a)damian.net