I have a query with 4 tables and plain 'JOIN's
the explain gives the best join order, and it completes in 1.5 secs
I add a single ORDER BY (a calculated column) and the join orders all shift
and the query takes 85secs!
So I read the docs and it suggests STRAIGHT_JOIN to force join order.
now I was using:
JOIN myTable ON xyx=abc
but in the docs it seems the ON condition is not permisible here, though it
does work.
Am I infact doing an 'INNER JOIN'? certainly if I change to INNER JOIN there
is no difference.
However the only way I can force the join order is to use STRAIGHT_JOIN that
does not accept an ON condition, so I have shifted the clauses to the WHERE
and it works fine.
Is there any syntax I can use to keep the ON conditions, I prefer this
approach it makes the code clearer regarding intent.
Here's the SELECT:
SELECT
place.id, pow((place.x*10 0)-423302,2)+pow(( place.y*100)-381522,2) AS
distance,
place.name, place.x, place.y
FROM place
STRAIGHT_JOIN placeNeighbours AS n ON place.id = n.place1
STRAIGHT_JOIN place AS place2 ON
pow((place.x*10 0)-(place2.x*100), 2)+pow((place.y *100)-(place2.y*100), 2) <
1600 AND place2.id = n.place2
STRAIGHT_JOIN shop ON shop.place = place2.id
GROUP BY place.id
HAVING distance <= 1.6E7
ORDER BY distance
LIMIT 0,10
--
Mike W 0 2340 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: B. Fongo |
last post by:
I learned MySQL last year without putting it into action; that is why
I face trouble in formulating my queries. Were it a test, then you
would have passed it, because your queries did help me solve my problem.
I'll turn to MySQL doc after getting through this pressing project.
Thanks a lot Roger!
Babale
-----Urspr=FCngliche Nachricht-----
|
by: VisionSet |
last post by:
I have a query with 4 tables and plain 'JOIN's
the explain gives the best join order, and it completes in 1.5 secs
I add a single ORDER BY (a calculated column) and the join orders all shift
and the query takes 85secs!
So I read the docs and it suggests STRAIGHT_JOIN to force join order.
now I was using:
|
by: tekanet |
last post by:
Hello folks,
first of all I really don't know how you gurus call this way of
writing joins:
SELECT
A.FIELD,
B.FIELD
FROM
TABLE_A A,
TABLE_B B
|
by: Anthony Robinson |
last post by:
I was actually just wondering if someone could possibly take a look
and tell me what I may be doing wrong in this query? I keep getting
ambiguous column errors and have no idea why...?
Thanks in advance!!!
SELECT AIM.AIMRETRIEVAL.AIMRETRIEVALID,
AIM.AIMRETRIEVAL.DESCRIPTION,
AIM.ARCHIVERETRIEVAL.ARCHIVERETRIEVALID,
AIM.ARCHIVERETRIEVAL.STATUSID,
|
by: Ben |
last post by:
I want to say:
SELECT tableA.stuff,tableB.morestuff,tableC.stillmorestuff
FROM tableA,
LEFT OUTER JOIN tableB ON (AB match conditions)
LEFT OUTER JOIN tableC ON (AC match conditions)
WHERE etc
However, in some cases, tableB does not have rows where the other two do
(it contains credit card records... but when an order is paid by check, there is
| |
by: Ben |
last post by:
I want to say:
SELECT tableA.stuff,tableB.morestuff,tableC.stillmorestuff
FROM tableA,
LEFT OUTER JOIN tableB ON (AB match conditions)
LEFT OUTER JOIN tableC ON (AC match conditions)
WHERE etc
However, in some cases, tableB does not have rows where the other two do
(it contains credit card records... but when an order is paid by check, there is
|
by: Jane T |
last post by:
I appreciate how difficult it is to resolve a problem without all the
information but maybe someone has come across a similar problem.
I have an 'extract' table which has 1853 rows when I ask for all rows where
period_ = 3. The allocation table for info has 210 rows.
I have two scripts below. The first script where I specify a period on a
join, brings back 1853 lines and works. The second script where I specify
the period in the...
|
by: gr8white |
last post by:
I'm running a query involving an outer join where one of the conditions is that the numeric value of a varchar field is between the numeric values of 2 varchar fields in another table (this has to do with an address range where in some cases the addresses include an alpha character). The query runs fine in the original database but for some reason it returns an "invalid number" error in another db against the exact same data, even though I am...
|
by: jackal_on_work |
last post by:
Hi Faculties,
I have two queries which give me the same output.
-- Query 1
SELECT prod.name, cat.name
FROM products prod INNER JOIN categories cat
ON prod.category_id = cat.id
WHERE cat.id = 1;
|
by: =?ISO-8859-1?Q?Ren=E9?= |
last post by:
Hi,
is there a rule of thumb what is better/faster/more performant in SQL
Server 2005?
a) SELECT * FROM A INNER JOIN B ON B.ID = A.ID AND B.Cond1 = 1 AND
B.Cond2 = 2
b) SELECT * FROM A INNER JOIN B ON B.ID = A.ID WHERE B.Cond1 = 1 AND
B.Cond2 = 2
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| | |