Database error: Couple=0

I am having a problem with mysql hanging as a result of the following.

Query:

SELECT
`Profiles`.*
FROM `Profiles` WHERE `Status` = 'Active'  AND (`Couple`=0 OR `Couple`>`ID`) ORDER BY `Couple` ASC, RAND() LIMIT 0, 9

Mysql error:
Sort aborted

Found error in file /usr/local/www/rainbow/html/networking/templates/base/scripts/BxBaseIndex.php
at line 474. Called db_res function
with erroneous argument #0

I manually need to abort these queries because they hang up the mysql resources.

The error line 474 in /BxBaseIndex.php is
if( $num )
{
--snip error line--
$result = db_res( $query.$filter.$limit );
--snip--

}

The reason for the error is probably that I have disabled "Couple" as a an option.  I don't know where it is even being searched.  I am guessing that there is a default somewhere.

I am not really understanding what this code is doing, but my guess is that it is failing to create a random number for the limit statement.

The Auto-report system produces lots of Array info, but this may be helpful in analysis.

Called script: /index.php

Request parameters:
Array
(
[members_mode] => rand
)

Anyone have a suggestion for an 'if' statement?

Arthur



Quote · 21 Oct 2008

What is the Couple field in the Profile table and why does this query consistently struggle and freeze resources.


SELECT  `Profiles`.*  FROM `Profiles` WHERE `Status` = 'Active'  AND (`Couple`=0 OR `Couple`>`ID`) ORDER BY `Couple` ASC, RAND() LIMIT 0, 9

To replicate the dolphin query, I have now just tried this at the mysql command line, and it does not produce a result in any reasonable amount of time.  It took 9 min 31 seconds to produce a result for:
SELECT  Profiles.*  FROM Profiles WHERE Status = "Active"  AND (Couple=0 OR Couple>"ID") ORDER BY Couple ASC, RAND() LIMIT 0, 9;


While this is running, my CPU% usage for mysql and LOAD AVERAGE on the machine elevate significantly.

In the statement itself, I don't see why it is attempting to ORDER BY a '0' value....or what the reason for comparing Couple to the ID in this part of the statement: Couple > ID .  If the value of Couple is '0' or '', what is the point of the comparison.  What is the value of Couple supposed to be, and why compare it to the ID field?

Anyone have a hint?  I am wondering if there is a better way to do this query.  Does it need to be ORDER BY an essentially useless field?

NOTE: After testing, I can see that the ORDER BY Couple ASC, RAND() is causing the problem. Anyone have any ideas on a better way to achieve the desired result? 

Arthur
Quote · 1 Nov 2008
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.