473,623 Members | 2,790 Online
Bytes | Software Development & Data Engineering Community
+ 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_numbe r, buildings.name as building_name,
buildings.id as building_id, accounts.name as account_name from
boiler_on_off_d ate LEFT join box ON
box.box_id=boil er_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_d ate.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_d ate | 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.buildin gs.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 1027

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

Similar topics

1
1872
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 running it through Analyzer, but when I call this stored proc running it throuhg my C# winforms app (running on computer z) it takes over 3 minutes on computer x and under 10 seconds on y. This stored proc does have a select clause as part of the...
7
31549
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" slows the system down considerably. I've tried creating a temp db, but I can't figure out how to execute two select commands. (It throws the exception "The column prefix 'tempdb' does not match with a table name or alias name used in the query.")
8
2633
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 Task_UID. SELECT PR.PROJ_NAME AS PRName, PR.PROJ_ID As PRProjID, PR.TASK_UID As PRTaskUID, 'Dev' AS GroupType, Feat.PROJ_ID As FeatProjID, Feat.TASK_UID As FeatTaskUID, Feat.FeatureID AS FeatureID,
3
3528
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 your collective opinion. Would building a comprehensive index on nullid.angus_is improve this statement's performance? merge into (select * from nullid.ANGUS_IN where bhid is null) t1 using (select ta.*, ts.regnum as sire_regnum, td.regnum as...
10
1855
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, V.FIELD04, V.FIELD05, V.FIELD06, V.FIELD07, V.FIELD08, V.FIELD09, V.FIELD10, V.FIELD11, V.FIELD12, V.FIELD13 FROM SCHEMA1.VIEW1 V WHERE V.FIELD2 BETWEEN '03/10/2005' AND '03/10/2006' AND (V.FIELD4 = '103' OR V.FIELD4 = '100' )
2
8432
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, SELECT * FROM TableA LEFT OUTER JOIN TableB
9
9214
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 filter my left table in the WHERE clause and cannot filter it in the FROM clause. This seems like it would cause a lot of overhead especially when my left table is ten thousand rows. Am I wrong in thinking that the two tables get joined with the...
8
5093
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 indexed). dbo.maintable(ProfileID int pk) dbo.fts_table(ProfileID int pk fk, col1 xml, col2 xml, col3 xml) I want to perform a query that will return any rows that contain ‘x’ and ‘y’ in any columns. I.e. ‘x’ could be in col1 and ‘y’ could be in
0
2770
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. The statement itself is not that complicated, it is 3 selects and union all. Explain output is pretty big, but I could not find anything unusual. I'm new to db2 and I could be missing stuff. I am posting the explain output below and I really...
0
8224
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8610
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 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...
1
8324
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,...
0
7145
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, 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...
1
6104
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5561
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();...
0
4070
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...
0
4156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1775
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.