September 23, 2009 at 1:13 pm
The current collation is Latin1_General_BIN. Would there be any benefit in changing this possibly atthe column level? If so, to what? Also, you will notice in the following query we are using the RTRIM function. This causes very poor performance. In Oracle it is easy to create a function based index. Is there a work around for this in SQL Server other than using computed columns? I would like to see it taken out completely and the RTRIM done when the data is loaded. We are looking into that as well.
SELECT customer.customer_no, customer.customer_id, upper(first_name) 'first_name', upper(last_name) 'last_name',
telephone_no, address_1, post_code, email_address , address_match_key
FROM customer (index (customer_x2)), address (index (address_x0))
WHERE rtrim(alpha_key) = N'BEDOYA TERE'
and customer.customer_id=address.customer_id
AND customer.active_address_id=address.address_id
and address_match_key LIKE N '07093%'
Best Regards,
~David
September 23, 2009 at 4:11 pm
David Kranes (9/23/2009)
Sorry for the delay in providing this. I have attached the DDL.
Where? Not on that post...
--Jeff Moden
Change is inevitable... Change for the better is not.
September 23, 2009 at 4:25 pm
Jeff Moden (9/23/2009)
David Kranes (9/23/2009)
Sorry for the delay in providing this. I have attached the DDL.Where? Not on that post...
It was there, I opened directly, but I since deleted what I had, sorry.
September 24, 2009 at 11:15 am
I would have thought the the word LIKE would have tipped things off. I thought that LIKE almost always performed a table scan. Nobody asked about how many rows in the tables.
ATBCharles Kincaid
September 24, 2009 at 11:26 am
Mr. Kincaid,
there are over 10 million rows in the tables. When forced to use the correct indexes, the LIKE clause poses no problems. The results return immediately.
Best Regards,
~David
September 24, 2009 at 11:43 am
David.
OK. Like I said "almost always". Are you always needing the % at the end of the string? If so then I would try ranging. (WHERE first_name>='Charles') If it needs to be anywhere then you might be stuck with the hints.
I'm sort of flying blind and shooting from the hip as I don't see any attachements for the plans or DDL. I've not had a perfect experience since moving to IE-8.
Please feel free to give the "Mr." a rest. Since the rest of the crowd on these forums have called me out using my first name you can join in too.
ATBCharles Kincaid
September 24, 2009 at 12:05 pm
Could you post the execution plan of the query without the index hints? That would probably be much more helpful in solving the problem. What appears to be happening is that the Query Optimizer doesn't believe that the existing indexes are good enough for this query. It is possible tht you may need a new index on each of the tables involved.
I'd also be interested in knowing a little more about the actual quesry as well, such as how is it used? Is it actually in a stored procedure that is used to pass parameters to the query?
September 24, 2009 at 12:06 pm
Also, could you repost the DDL? I had them for a while yesterday, but I opened them directly and did not save it on my system.
September 24, 2009 at 12:43 pm
Lynn, this query is actually generated dynamically through a stored procedure based on input from the application. I have attached the query plan.
Best Regards,
~David
September 24, 2009 at 12:44 pm
Here is the DDL. Thank you.
Best Regards,
~David
September 24, 2009 at 5:19 pm
David Kranes (9/24/2009)
Here is the DDL. Thank you.
There real problem is that the "Active_Address_ID" has no index on it nor is it a part of any other index, yet you're using it as a part of the join criteria in the WHERE clause. Adding the correct index should make the lookup virtually instantaneous.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 11 posts - 16 through 25 (of 25 total)
You must be logged in to reply to this topic. Login to reply