473,466 Members | 1,349 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

LEFT JOIN limitations ??

Hello,
I have a strange problem, maybe some of you will be able to explain me
something. I use LEFT JOIN as a substitute for subselects. It's true
that many subselects can be rewriten using LEFT JOIN. I have made a
query which use LEFT JOIN statement and... when there are many LEFT
JOIN's (over 3) on the same table MySQL execute this query very long
time... few hours or more. Maybe there is something wrong with my table
structures... Are there any limitations for LEFT JOIN ??

Below the query, and table structures...

-- QUERY

SELECT
DISTINCT
_NEW.news_id,
_NNA.title,
IF(LENGTH(_NNA.content) > 250, CONCAT(SUBSTRING(_NNA.content, 1,
250),'...'), _NNA.content) AS content,
_NEW.publish_date
FROM
new_news _NEW,
new_news_names_search _NNA
LEFT JOIN new_news_categorys _CAT21 ON _CAT21.news_id = _NEW.news_id
AND _CAT21.category_id IN (21)
LEFT JOIN new_news_categorys _CAT18 ON _CAT18.news_id = _NEW.news_id
AND _CAT18.category_id IN (18)
LEFT JOIN new_news_categorys _CAT50 ON _CAT50.news_id = _NEW.news_id
AND _CAT50.category_id IN (50)
LEFT JOIN new_news_categorys _CAT1 ON _CAT1.news_id = _NEW.news_id AND
_CAT1.category_id IN (1,2,3,17,19,30,37)
WHERE
_NEW.publish_date <= NOW() AND
_NNA.news_id = _NEW.news_id AND
_NNA.language_id = '1' AND
_CAT21.news_id > 0 AND
_CAT18.news_id > 0 AND
_CAT50.news_id > 0 AND
_CAT1.news_id > 0
ORDER BY
_NEW.publish_date DESC
#
# Table structure for table 'new_news_categorys'
#

CREATE TABLE new_news_categorys (
news_id int(10) NOT NULL default '0',
category_id int(10) NOT NULL default '0',
PRIMARY KEY (news_id,category_id),
KEY category_id (category_id),
CONSTRAINT 0_1901 FOREIGN KEY (news_id) REFERENCES new_news (news_id)
ON DELETE CASCADE,
CONSTRAINT 0_1902 FOREIGN KEY (category_id) REFERENCES
set_new_news_categorys (category_id) ON DELETE CASCADE
) TYPE=InnoDB;

#
# Table structure for table 'new_news_names'
#

CREATE TABLE new_news_names (
news_id int(10) NOT NULL default '0',
language_id int(10) NOT NULL default '0',
title longtext,
content longtext,
PRIMARY KEY (news_id,language_id),
KEY news_id (news_id),
KEY language_id (language_id),
CONSTRAINT 0_1909 FOREIGN KEY (news_id) REFERENCES new_news (news_id)
ON DELETE CASCADE
) TYPE=InnoDB;

#
# Table structure for table 'new_news_names_search'
#

CREATE TABLE new_news_names_search (
news_id int(11) NOT NULL default '0',
language_id int(11) NOT NULL default '0',
title longtext,
content longtext,
PRIMARY KEY (news_id,language_id),
FULLTEXT KEY title (title,content)
) TYPE=MyISAM;

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/my***********...ie.nctu.edu.tw

Jul 19 '05 #1
0 2425

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

Similar topics

0
by: Marek Lewczuk | last post by:
Hello, I have a strange problem, maybe some of you will be able to explain me something. I use LEFT JOIN as a substitute for subselects. It's true that many subselects can be rewriten using LEFT...
0
by: Petre Agenbag | last post by:
Hi List Me again. I'm trying to return from multiple tables, the records that have field "information_sent" between two dates. The tables are all related by means of the id of the entry in the...
0
by: Soefara | last post by:
Dear Sirs, I am experiencing strange results when trying to optimize a LEFT JOIN on 3 tables using MySQL. Given 3 tables A, B, C such as the following: create table A ( uniqueId int not...
1
by: Paul Bramscher | last post by:
Here's one for pathological SQL programmers. I've got a table of things called elements. They're components, sort of like amino acids, which come together to form complex web pages -- as nodes...
4
by: jbm05 | last post by:
Hi, I'm curious about the computational complexity of a query I have. The query contains multiple nested self left joins, starting with a simple select, then doing a self left join with the...
3
by: Dam | last post by:
Using SqlServer : Query 1 : SELECT def.lID as IdDefinition, TDC_AUneValeur.VALEURDERETOUR as ValeurDeRetour FROM serveur.Data_tblDEFINITIONTABLEDECODES def,...
3
by: Ian Boyd | last post by:
i know nothing about DB2, but i'm sure this must be possible. i'm trying to get a client to create a view (which it turns out is called a "Logical" in DB2). The query needs a LEFT OUTER JOIN, but...
2
by: tricard | last post by:
Good day all, I have a large outer joined query that I want to have some criteria. The select query is gathering all part numbers from tblPartNumbers, left joining to tblPartNumberVendor (since...
1
by: naveenchhibber | last post by:
Hi all pls tell me that the following statment is valid in oracle 9i or 10g.. update ws set received_by_facility = coalesce(rbf_ouk.organizational_unit_id, 0), ...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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
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.