<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[PunBB Forums - limiting search results (biggest punbb problem for me)]]></title>
	<link rel="self" href="http://punbb.informer.com/forums/feed/atom/topic/21379/"/>
	<updated>2009-04-10T12:53:23Z</updated>
	<generator>PunBB</generator>
	<id>http://punbb.informer.com/forums/topic/21379/limiting-search-results-biggest-punbb-problem-for-me/</id>
		<entry>
			<title type="html"><![CDATA[Re: limiting search results (biggest punbb problem for me)]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/126688/#p126688"/>
			<content type="html"><![CDATA[<div class="quotebox"><cite>gorsan wrote:</cite><blockquote><p>i am being forced to convert smf now, which seems the correct way to go since i could not upgrade to punbb 1.3 because of utf8 problems which i cant really solve.</p></blockquote></div><p>Why? You haven&#039;t even added a limit to those two queries you posted above, so obviously they will return all matches.</p><p>That first query:</p><div class="codebox"><pre><code>                $result = $db-&gt;query(&#039;SELECT t.id FROM &#039;.$db-&gt;prefix.&#039;posts AS p INNER JOIN &#039;.$db-&gt;prefix.&#039;topics AS t ON t.id=p.topic_id INNER JOIN &#039;.$db-&gt;prefix.&#039;forums AS f ON f.id=t.forum_id LEFT JOIN &#039;.$db-&gt;prefix.&#039;forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=&#039;.$pun_user[&#039;g_id&#039;].&#039;) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id IN(&#039;.implode(&#039;,&#039;, $search_ids).&#039;)&#039;.$forum_sql.&#039; GROUP BY t.id&#039;, true) or error(&#039;Unable to fetch topic list&#039;, __FILE__, __LINE__, $db-&gt;error());</code></pre></div><p>should be:</p><div class="codebox"><pre><code>                $result = $db-&gt;query(&#039;SELECT t.id FROM &#039;.$db-&gt;prefix.&#039;posts AS p INNER JOIN &#039;.$db-&gt;prefix.&#039;topics AS t ON t.id=p.topic_id INNER JOIN &#039;.$db-&gt;prefix.&#039;forums AS f ON f.id=t.forum_id LEFT JOIN &#039;.$db-&gt;prefix.&#039;forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=&#039;.$pun_user[&#039;g_id&#039;].&#039;) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id IN(&#039;.implode(&#039;,&#039;, $search_ids).&#039;)&#039;.$forum_sql.&#039; GROUP BY t.id LIMIT 50&#039;, true) or error(&#039;Unable to fetch topic list&#039;, __FILE__, __LINE__, $db-&gt;error());</code></pre></div><p>Do the same for the second query.</p><br /><div class="quotebox"><blockquote><p>stats.punres will have a new number 1 forum soon.</p></blockquote></div><p>The point? This board isn&#039;t commercial, hence any responses are from people volunteering their time to responding. That approach is hardly liable to make people jump at your behest.</p>]]></content>
			<author>
				<name><![CDATA[MattF]]></name>
				<uri>http://punbb.informer.com/forums/user/9938/</uri>
			</author>
			<updated>2009-04-10T12:53:23Z</updated>
			<id>http://punbb.informer.com/forums/post/126688/#p126688</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: limiting search results (biggest punbb problem for me)]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/126632/#p126632"/>
			<content type="html"><![CDATA[<p>@gorsan: Do you get an error when trying to upgrade to 1.3?<br />If so, Let me know what the error is and I will try and help you.</p>]]></content>
			<author>
				<name><![CDATA[Smith]]></name>
				<uri>http://punbb.informer.com/forums/user/15232/</uri>
			</author>
			<updated>2009-04-09T20:22:18Z</updated>
			<id>http://punbb.informer.com/forums/post/126632/#p126632</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: limiting search results (biggest punbb problem for me)]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/126598/#p126598"/>
			<content type="html"><![CDATA[<p>i am being forced to convert smf now, which seems the correct way to go since i could not upgrade to punbb 1.3 because of utf8 problems which i cant really solve.</p><p>stats.punres will have a new number 1 forum soon.</p>]]></content>
			<author>
				<name><![CDATA[gorsan]]></name>
				<uri>http://punbb.informer.com/forums/user/13930/</uri>
			</author>
			<updated>2009-04-09T11:18:48Z</updated>
			<id>http://punbb.informer.com/forums/post/126598/#p126598</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: limiting search results (biggest punbb problem for me)]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/126385/#p126385"/>
			<content type="html"><![CDATA[<p>could you please help me</p><p>my users are forcing me to open search.php again<br />it is impossible without limiting 2 million posts<br />i found i have to limit these querries and i found i have to do something like this link <br /><a href="http://lists.mysql.com/mysql/209407">http://lists.mysql.com/mysql/209407</a><br />example:<br /></p><div class="codebox"><pre><code>&gt;&gt; SELECT points
&gt;&gt; FROM results
&gt;&gt; WHERE
&gt;&gt; (
&gt;&gt;  SELECT count(*)
&gt;&gt;  FROM results as R
&gt;&gt;  WHERE R.person_id = results.person_id AND R.points &gt; results.points
&gt;&gt; ) &lt;3
&gt;&gt; ORDER BY person_id, points DESC</code></pre></div><p>but cant do it, the lines i have to change is below </p><div class="codebox"><pre><code>if ($show_as == &#039;topics&#039;)
            {
                $result = $db-&gt;query(&#039;SELECT t.id FROM &#039;.$db-&gt;prefix.&#039;posts AS p INNER JOIN &#039;.$db-&gt;prefix.&#039;topics AS t ON t.id=p.topic_id INNER JOIN &#039;.$db-&gt;prefix.&#039;forums AS f ON f.id=t.forum_id LEFT JOIN &#039;.$db-&gt;prefix.&#039;forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=&#039;.$pun_user[&#039;g_id&#039;].&#039;) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id IN(&#039;.implode(&#039;,&#039;, $search_ids).&#039;)&#039;.$forum_sql.&#039; GROUP BY t.id&#039;, true) or error(&#039;Unable to fetch topic list&#039;, __FILE__, __LINE__, $db-&gt;error());

                $search_ids = array();
                while ($row = $db-&gt;fetch_row($result))
                    $search_ids[] = $row[0];

                $db-&gt;free_result($result);

                $num_hits = count($search_ids);
            }
            else
            {
                $result = $db-&gt;query(&#039;SELECT p.id FROM &#039;.$db-&gt;prefix.&#039;posts AS p INNER JOIN &#039;.$db-&gt;prefix.&#039;topics AS t ON t.id=p.topic_id INNER JOIN &#039;.$db-&gt;prefix.&#039;forums AS f ON f.id=t.forum_id LEFT JOIN &#039;.$db-&gt;prefix.&#039;forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=&#039;.$pun_user[&#039;g_id&#039;].&#039;) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id IN(&#039;.implode(&#039;,&#039;, $search_ids).&#039;)&#039;.$forum_sql, true) or error(&#039;Unable to fetch topic list&#039;, __FILE__, __LINE__, $db-&gt;error());

                $search_ids = array();
                while ($row = $db-&gt;fetch_row($result))
                    $search_ids[] = $row[0];

                $db-&gt;free_result($result);

                $num_hits = count($search_ids);
            }</code></pre></div>]]></content>
			<author>
				<name><![CDATA[gorsan]]></name>
				<uri>http://punbb.informer.com/forums/user/13930/</uri>
			</author>
			<updated>2009-04-03T19:47:14Z</updated>
			<id>http://punbb.informer.com/forums/post/126385/#p126385</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: limiting search results (biggest punbb problem for me)]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/126089/#p126089"/>
			<content type="html"><![CDATA[<div class="codebox"><pre><code>if ($show_as == &#039;posts&#039;)
        {
            $substr_sql = ($db_type != &#039;sqlite&#039;) ? &#039;SUBSTRING&#039; : &#039;SUBSTR&#039;;
            $sql = &#039;SELECT p.id AS pid, p.poster AS pposter, p.posted AS pposted, p.poster_id, &#039;.$substr_sql.&#039;(p.message, 1, 1000) AS message, t.id AS tid, t.poster, t.subject, t.question, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.forum_id, t.labels FROM &#039;.$db-&gt;prefix.&#039;posts AS p INNER JOIN &#039;.$db-&gt;prefix.&#039;topics AS t ON t.id=p.topic_id WHERE p.id IN(&#039;.$search_results.&#039;) ORDER BY &#039;.$sort_by_sql.&#039;DESC LIMIT 50&#039;;
        }
        else
            //$sql = &#039;SELECT t.id AS tid, t.poster, t.subject, t.question, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id FROM &#039;.$db-&gt;prefix.&#039;posts AS p INNER JOIN &#039;.$db-&gt;prefix.&#039;topics AS t ON t.id=p.topic_id WHERE t.id IN(&#039;.$search_results.&#039;) GROUP BY t.id, t.poster, t.subject, t.question, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id&#039;.$group_by_sql.&#039; ORDER BY &#039;.$sort_by_sql;
            $sql = &#039;SELECT t.id AS tid, t.poster, t.subject, t.question, t.sticky, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id, t.labels FROM &#039;.$db-&gt;prefix.&#039;topics AS t WHERE t.id IN(&#039;.$search_results.&#039;) ORDER BY &#039;.$sort_by_sql.&#039;DESC LIMIT 50&#039;;</code></pre></div><p>and then i had to delete this line <br />$sql .= &#039; &#039;.$sort_dir.&#039; LIMIT &#039;.$start_from.&#039;, &#039;.$per_page;</p><br /><p>well it did not optimize anything or searches i may be doing something wrong</p><p>thanks anyway.</p>]]></content>
			<author>
				<name><![CDATA[gorsan]]></name>
				<uri>http://punbb.informer.com/forums/user/13930/</uri>
			</author>
			<updated>2009-03-25T01:52:36Z</updated>
			<id>http://punbb.informer.com/forums/post/126089/#p126089</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: limiting search results (biggest punbb problem for me)]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/126065/#p126065"/>
			<content type="html"><![CDATA[<p>Add Limit 50 to the end of the query where it retives the posts/topics.</p>]]></content>
			<author>
				<name><![CDATA[Utchin]]></name>
				<uri>http://punbb.informer.com/forums/user/9648/</uri>
			</author>
			<updated>2009-03-24T19:05:39Z</updated>
			<id>http://punbb.informer.com/forums/post/126065/#p126065</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: limiting search results (biggest punbb problem for me)]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/126052/#p126052"/>
			<content type="html"><![CDATA[<p>thank you so much is there any solution for punbb 1.2 also ?</p>]]></content>
			<author>
				<name><![CDATA[gorsan]]></name>
				<uri>http://punbb.informer.com/forums/user/13930/</uri>
			</author>
			<updated>2009-03-24T12:56:53Z</updated>
			<id>http://punbb.informer.com/forums/post/126052/#p126052</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: limiting search results (biggest punbb problem for me)]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/126045/#p126045"/>
			<content type="html"><![CDATA[<p>Go to &lt;FORUM_ROOT&gt;/inlcude/search_functions.php go to line 643 and replace this code<br /></p><div class="codebox"><pre><code>&#039;ORDER BY&#039;    =&gt; &#039;t.last_post DESC&#039;</code></pre></div><p>with this <br /></p><div class="codebox"><pre><code>&#039;ORDER BY&#039;  =&gt; &#039;t.last_post DESC&#039;,
&#039;LIMIT&#039;     =&gt; &#039;50&#039;</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Slavok]]></name>
				<uri>http://punbb.informer.com/forums/user/13265/</uri>
			</author>
			<updated>2009-03-24T09:29:33Z</updated>
			<id>http://punbb.informer.com/forums/post/126045/#p126045</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[limiting search results (biggest punbb problem for me)]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/126029/#p126029"/>
			<content type="html"><![CDATA[<p>is it possible to limit search results</p><p>go in this url and see <a href="http://mypunbb.com/search.php?action=show_unanswered">http://mypunbb.com/search.php?action=show_unanswered</a><br />it opens in 30 whole seconds</p><p>well in my own forum it is much worse</p><p>how can we limit search results for the first 50 topics for example</p><p>P.S. this is same in punbb 1.3 i should have posted this at bugs.</p><p>Anyone please help<br />thank you.</p>]]></content>
			<author>
				<name><![CDATA[gorsan]]></name>
				<uri>http://punbb.informer.com/forums/user/13930/</uri>
			</author>
			<updated>2009-03-23T23:20:44Z</updated>
			<id>http://punbb.informer.com/forums/post/126029/#p126029</id>
		</entry>
</feed>
