MySQL MAX_JOIN_SIZE错误 [英] MySQL MAX_JOIN_SIZE errors

查看:507
本文介绍了MySQL MAX_JOIN_SIZE错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我代表一小群有此问题的用户问这个问题.

I am asking this question on behalf of a small group of my users that have this problem.

他们使用的脚本一旦获得第21个ID,就会产生以下错误:

Once the script they are using gets to the 21st ID, it generates the following error:

SELECT会检查以下内容: MAX_JOIN_SIZE行;检查你的位置 并使用SET SQL_BIG_SELECTS = 1或SET SQL_MAX_JOIN_SIZE =#如果SELECT是 好吧

The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay

我已对此进行了尽可能多的研究,并找到了答案:

I have researched this as much as possible and found something of an answer : http://dev.mysql.com/doc/refman/5.0/en/set-option.html

问题在于它们位于共享主机上,因此它们无法更改MySQL设置来修复错误.

The problem is that they are on shared hosting so they cannot change their MySQL settings to fix the errors.

我可以在脚本中写些什么,以使他们没有这个问题吗?

Is there anything I can write into my script so that they do not have this problem?

此函数可根据加载的模块生成数据库查询: $ sql ='选择a.id作为id,a.address作为地址';

This is the function that generates the database query based on which modules are loaded: $sql = 'SELECT a.id as id , a.address as address';

        $query  = 'SELECT'
                . ' name AS module_name'
                . ', databasename AS module_database'
                . ', pregmatch AS module_pregmatch'
                . ', pregmatch2 AS module_pregmatch2'
                . ', html AS module_html'
                . ', sqlselect AS database_sqlselect'
                . ', sqljoin AS database_sqljoin'
                . ', sqlupdatewithvalue AS database_sqlupdatewithvalue'
                . ', sqlupdatenovalue AS database_sqlupdatenovalue'
                . ' FROM #__aqsgmeta_modules'
                . ' WHERE enabled = 1'
                . ' ORDER BY id';                       
        $db->setQuery($query);
        $results = $db->loadObjectList();
        if (count($results) != 0) {
            foreach ($results as $result) {
                $sqlselect .= ', ';
                $sqlselect .= $result->database_sqlselect;

                $sqljoin .= ' ';
                $result->database_sqljoin = preg_replace('/\{DATABASENAME\}/Ui', $result->module_database, $result->database_sqljoin);
                if (!(preg_match("/" . $result->database_sqljoin . "/Ui", $sqljoin))) 
                    $sqljoin .= $result->database_sqljoin;
            }
        }

        if ($use_sh404sef)
            $sqlselect .= ', g.oldurl AS sefurl';
        $sql .= $sqlselect;
        $sql .= ' FROM #__aqsgmeta_address AS a';
        $sql .= $sqljoin;

        if ($use_sh404sef)
            $sql .= ' LEFT JOIN #__redirection AS g ON g.newurl = a.address';

        $sql .=
        //. ' WHERE a.id IN (' . $cids . ')'
        ' WHERE a.id = ' . $id
        . ' ORDER BY a.address asc,a.id '
        ;
        $db->setQuery($sql);
        $rows = $db->loadObjectList();

推荐答案

MAX_JOIN_SIZE是共享主机上常用的安全防护.

MAX_JOIN_SIZE is a safety catch commonly used on the shared hostings.

它不会让您意外地运行长时间的查询,而这会使服务器挂起.

It won't let you accidentally run long queries which would hang the server.

发出此命令:

SET SQL_BIG_SELECTS = 1

在运行查询之前,您会返回很多值.

before running the query you know to return lots of values.

这篇关于MySQL MAX_JOIN_SIZE错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆