473,386 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Query not appearing to use an index

B
Hello

I have written the below query:

select CONCAT_WS(" ",m.c_salutation, UPPER(left(m.c_firstname,1)),'&',
f.c_salutation, UPPER(left(f.c_firstname,1)), f.c_lastname),
ad1.ad_address1, ad1.ad_address2
from xin_contacts as m,
xin_contacts as f,
em_parent_child_map as m2,
em_parent_child_map as f2,
xin_address as ad1
where m2.pc_parent_id = m.c_id
and f2.pc_parent_id = f.c_id
and f2.pc_parent_id <> m2.pc_parent_id
and f2.pc_student_id = m2.pc_student_id
and m2.pc_correspondance_contact = 'Y'
and f2.pc_correspondance_contact = 'Y'
and (ad1.ad_owners like CONCAT("%","|",m.c_id,"|","%") OR
ad1.ad_owners LIKE CONCAT(m.c_id,"|","%") OR ad1.ad_owners LIKE
CONCAT("%","|",m.c_id))
and upper(m.c_lastname) = upper(f.c_lastname)
GROUP BY 1,2

I have an index on em_parent_child_map.pc_parent_id but when I run an
explain on the query I get this:

+-------+--------+---------------+---------+---------+-----------------+-------+----------------------------------------------+
| table | type | possible_keys | key | key_len | ref
| rows | Extra |
+-------+--------+---------------+---------+---------+-----------------+-------+----------------------------------------------+
| m2 | ALL | pc_parent_id | NULL | NULL | NULL
| 9166 | Using where; Using temporary; Using filesort |
| ad1 | ALL | NULL | NULL | NULL | NULL
| 10767 | |
| m | eq_ref | PRIMARY | PRIMARY | 8 | m2.pc_parent_id
| 1 | Using where |
| f2 | ALL | pc_parent_id | NULL | NULL | NULL
| 9166 | Using where |
| f | eq_ref | PRIMARY | PRIMARY | 8 | f2.pc_parent_id
| 1 | Using where |
Why does the query find the key (list it in possible keys) but then
seem to not use it (ie put no entry in the key colum)?

Any help would be appreciated.

Thanks

Brendan
Jul 19 '05 #1
0 837

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

Similar topics

0
by: B | last post by:
Hello I have written the below query: select CONCAT_WS(" ",m.c_salutation, UPPER(left(m.c_firstname,1)),'&', f.c_salutation, UPPER(left(f.c_firstname,1)), f.c_lastname), ad1.ad_address1,...
3
by: Paul Mateer | last post by:
Hi, I have been running some queries against a table in a my database and have noted an odd (at least it seems odd to me) performance issue. The table has approximately 5 million rows and...
6
by: Steven D.Arnold | last post by:
I have a query which does not use column indexes that it should use. I have discovered some interesting behaviors of Postgres which may indicate a bug in the database's query planning. Take a...
1
by: jsegars | last post by:
I have a table with the following 2 fields: Serial # ( values range 1 to 1400 and represent a birth certif #) Location (text field that is the name of a geographical location appearing on the...
21
by: CSN | last post by:
I have a pretty simple select query that joins a table (p) with 125K rows with another table (pc) with almost one million rows: select p.* from product_categories pc inner join products p on...
0
by: Owen Jenkins | last post by:
Hi, My application allows users to create a new back end for separate purposes. It does this by using Make Table Queries and Indexing via SQL. For example ... sqlString = "SELECT * INTO " &...
4
by: Owen Jenkins | last post by:
Hi, No-one replied to this when I sent it last week. Any bites out there today?? ----- My application allows users to create a new back end for separate purposes. It does this by using Make...
3
by: jaimebienlesfruits | last post by:
Hi, In my main content section, I have a div tag (containing a background image). Embedded with this div tag is another div tag for actual text (h1, p, etc) and another div tag for the sidebar....
0
by: HankC | last post by:
I have created a form in vb.net that generates the follwoing code, but only the three labels appear and they are all in the upper left corner rather than scattered over the form... Can anyone...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.