473,493 Members | 2,245 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Help: Join Performance, Not Recognizing Index

Joe
I'm trying to get the following query optimized:

SELECT box.box_id, box.phone_number, buildings.name as building_name,
buildings.id as building_id, accounts.name as account_name from
boiler_on_off_date LEFT join box ON
box.box_id=boiler_on_off_date.box_id LEFT join buildings FORCE INDEX
(id) ON buildings.id = box.building_id LEFT join accounts ON
accounts.id = buildings.owner_id WHERE boiler_on_off_date.timestamp >
'2005-10-05' GROUP by box.box_id;

Explain Shows the following:

+----+-------------+--------------------+--------+---------------+---------+---------+-----------------------------------+--------+-----------------------------------------------------------+
| id | select_type | table | type | possible_keys | key
| key_len | ref | rows | Extra
|
+----+-------------+--------------------+--------+---------------+---------+---------+-----------------------------------+--------+-----------------------------------------------------------+
| 1 | SIMPLE | boiler_on_off_date | index | NULL |
PRIMARY | 12 | NULL | 192053 | Using
where; Using index; Using temporary; Using filesort |
| 1 | SIMPLE | box | eq_ref | PRIMARY |
PRIMARY | 4 | usemgmt.boiler_on_off_date.box_id | 1 |
|
| 1 | SIMPLE | buildings | ALL | id | NULL
| NULL | NULL | 945 |
|
| 1 | SIMPLE | accounts | eq_ref | PRIMARY,id | id
| 15 | usemgmt.buildings.owner_id | 1 |
|
+----+-------------+--------------------+--------+---------------+---------+---------+-----------------------------------+--------+-----------------------------------------------------------+
4 rows in set (0.00 sec)
The problem is the buildings JOIN using type=ALL, which is REALLY slow.
What doesn't make sense is that im joinging building using:

LEFT join buildings FORCE INDEX (id) ON buildings.id = box.building_id

and buildings.id is the PRIMARY KEY on buildings. I also used the FORCE
INDEX(id), which doesn't make any difference either.

Any ideas why buildings is being joined USING ALL and not eq_ref?

Thanks,
Jow

Oct 7 '05 #1
0 1017

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

Similar topics

1
1859
by: Voss | last post by:
Here's what's going on. I have a 2 computers (x & y) running SQL2000. I backed up a copy a DB from x and restored it on y. I have a Stored proc that runs in under 2 seconds on both x & y when...
7
31534
by: Steve | last post by:
I have a SQL query I'm invoking via VB6 & ADO 2.8, that requires three "Left Outer Joins" in order to return every transaction for a specific set of criteria. Using three "Left Outer Joins"...
8
2622
by: Xu, Wei | last post by:
Hi, I have wrote the following sql sentence.Do you have comments to improve the performance.I have created all the indexed. But it's still very slow.Thanks The primary key is proj_ID and...
3
3512
by: Bob Stearns | last post by:
We have a very poorly performing MERGE statement (an hour or more on tables of ~10000 and ~100000). This may require building temporary tables with appropriate indexes, but I thought I would ask...
10
1838
by: varlagas | last post by:
I execute a query (against DB2 for iSeries), which, in its generic form is as follows. This query runs just fine, executing in a couple of seconds SELECT V.FIELD01, V.FIELD02, V.FIELD03,...
2
8423
by: lelandhuang | last post by:
I am developing reporting service and using lots of 'LEFT OUTER JOIN', I am worried about the performance and want to use some subquery to improve the performance. Could I do that like below, ...
9
9200
by: shanevanle | last post by:
I have two tables that are pretty big. I need about 10 rows in the left table and the right table is filtered to 5 rows as well. It seems when I join the tables in the FROM clause, I have to...
8
5083
by: Sham | last post by:
I am trying to perform the following query on a table that has been indexed using Full Text Search. The table contains multiple columns than have been indexed. (Below, all xml columns are...
0
2761
by: LanaR | last post by:
Hello, one sql statement is causing severe performance issue. The problem occurs only in UDB environment, the same statemnt on the mainframe is running fine. I have an explain output from the sql....
0
7119
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
6989
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
7195
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...
1
6873
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
7367
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
3088
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...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1400
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 ...
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.