473,399 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

SET SQL_BIG_SELECTS=1

Hi Everyone

I've had a database query page running on a site for a few months:
(http://www.learningdirectory.info/search.php) with no problems.

The search page contains the following query:

SELECT CourseID, tblCourseInfo.ProviderID, tblCourseInfo.OccupationID,
tblCourseInfo.AuthorityID, tblOccupations.Occupation,
tblOccupations.OccupationID, tblProviders.ProviderID,
tblProviders.ProvName, tblAuthorities.AuthorityID,
tblAuthorities.Authority
FROM tblCourseInfo, tblOccupations, tblProviders, tblAuthorities
WHERE tblCourseInfo.ProviderID LIKE 'varProvider'
AND tblCourseInfo.OccupationID LIKE 'varOccupation'
AND tblCourseInfo.AuthorityID LIKE 'varAuthority'
AND tblCourseInfo.OccupationID LIKE tblOccupations.OccupationID
AND tblCourseInfo.ProviderID LIKE tblProviders.ProviderID
AND tblCourseInfo.AuthorityID LIKE tblAuthorities.AuthorityID
ORDER BY tblOccupations.Occupation, tblProviders.ProvName,
tblAuthorities.Authority

But in the last few days a message has appeared:
'The SELECT would examine more rows than MAX_JOIN_SIZE. Check your
WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the
SELECT is ok'

I understand that I need to add ''SET SQL_BIG_SELECTS=1' but could
someone please tell me where or how I add it? I haven't got a clue!!

Many thanks
Suffrinmick

Nov 24 '05 #1
1 29351
pa**@is-d.co.uk wrote:
Hi Everyone

I've had a database query page running on a site for a few months:
(http://www.learningdirectory.info/search.php) with no problems.

The search page contains the following query:

SELECT CourseID, tblCourseInfo.ProviderID, tblCourseInfo.OccupationID,
tblCourseInfo.AuthorityID, tblOccupations.Occupation,
tblOccupations.OccupationID, tblProviders.ProviderID,
tblProviders.ProvName, tblAuthorities.AuthorityID,
tblAuthorities.Authority
FROM tblCourseInfo, tblOccupations, tblProviders, tblAuthorities
WHERE tblCourseInfo.ProviderID LIKE 'varProvider'
AND tblCourseInfo.OccupationID LIKE 'varOccupation'
AND tblCourseInfo.AuthorityID LIKE 'varAuthority'
AND tblCourseInfo.OccupationID LIKE tblOccupations.OccupationID
AND tblCourseInfo.ProviderID LIKE tblProviders.ProviderID
AND tblCourseInfo.AuthorityID LIKE tblAuthorities.AuthorityID
ORDER BY tblOccupations.Occupation, tblProviders.ProvName,
tblAuthorities.Authority
This is not related to your question about SET, but I notice that you're
using the "LIKE" predicate where you could more efficiently use the "="
equality operator.

You can also use aliases to reduce having to retype the table names, and
I think using JOIN syntax is more clear than putting join conditions in
the WHERE clause.

Here is how I would write this query:

SELECT C.CourseID, O.Occupation, O.OccupationID, P.ProviderID,
P.ProvName, A.AuthorityID, A.Authority
FROM tblCourseInfo AS C
INNER JOIN tblOccupations AS O ON C.OccupationID = O.OccupationID
INNER JOIN tblProviders AS P ON C.ProviderID = P.ProviderID
INNER JOIN tblAuthorities AS A ON C.AuthorityID = A.AuthorityID
WHERE C.ProviderID = 'varProvider'
AND C.OccupationID = 'varOccupation'
AND C.AuthorityID = 'varAuthority'
ORDER BY O.Occupation, P.ProvName, A.Authority

Using "=" instead of "LIKE" should run a bit faster. "LIKE" is a
pattern-matching function, not a string equality function. Use "LIKE"
when you need wildcards in the comparison.
See http://dev.mysql.com/doc/refman/5.0/...functions.html
But in the last few days a message has appeared:
'The SELECT would examine more rows than MAX_JOIN_SIZE. Check your
WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the
SELECT is ok'

I understand that I need to add ''SET SQL_BIG_SELECTS=1' but could
someone please tell me where or how I add it? I haven't got a clue!!


It's a separate statement, which you can execute at any time before you
execute your SELECT. The setting remains in effect during the current
database session between your PHP application and the database.
See http://dev.mysql.com/doc/refman/5.0/en/set-option.html

For example:

SET SESSION SQL_BIG_SELECTS=1;
SELECT C.CourseID, ... <the rest of the query>;

You can also set this variable permanently for all sessions by adding it
to an options file on your MySQL server. See
http://dev.mysql.com/doc/refman/5.0/...ion-files.html.

Regards,
Bill K.
Nov 24 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Randell D. | last post by:
I'm using MySQL 4.0.16 on a LAMPhp server with Dreamweaver MX on a windoze client. To help me work, I also use MySQL Control Client 0.9.2 (The most recent 0.9.3 doesn't startup on my win-me...
0
by: paul | last post by:
Hi Everyone I've had a database query page running on a site for a few months: (http://www.learningdirectory.info/search.php) with no problems. The search page contains the following query: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.