473,463 Members | 1,552 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 29356
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.