Guys, this has been a great learning experience for me. Thank you for your input! I must (again) confess my ignorance in that I did not know what a CTE was. I Googled around and found some examples. I then basically wrappered the whole SELECT clause with WITH T AS (SELECT..........) and moved the LIKE statement to the second SELECT. This still caused CQE to be used......so after a little trial and error, I found that if I defined a field in the first select that only contained the first 8 characters of the field I wanted check and then used that in the second SELECT statement, SQE was used and the results and perfomance were great!

Unfortunately, ShowCase Query did not like the WITH clause. However, I am done with the analysis for now and have turned it back over to our Decision support group for them to work things out with ShowCase.

Once again, thanks for the great lessons! Who says old rpg'ers can't learn new tricks?

Joe Wells

Elvis Budimlic<ebudimlic-Ebbh53c6wcYkzXN11fiE55igCaZBIYHkAL8bYrjMMd8@xxxxxxxxxxxxxxxx> 09/11/07 10:57 AM >>>
Rewrite is definitely worth a try.

Couple of years ago I rewrote some of my poorly performing statements using
IN clause to use a subquery with an EXISTS clause and gained tremendous
performance gains (don't hold me to this, query optimizer changes daily :)).

What happens underneath is that query is rewritten by the query optimizer.
If it comes up with same query as before, you've gained nothing. However,
if it comes up with something even slightly different, it COULD come up with
a totally different access plan.
Go for it, Joe.

Elvis

-----Original Message-----
Subject: RE: SQL Select Statement Woes

I wonder if using CTE could help. If he could filter the SCHDETAIL table
(12 million records) to eliminate rows BEFORE doing the joins and LIKE
clauses. The OP stated that without the LIKE, the select returned 25 rows,
of which 5 were returned with the LIKE.

The objective would be to eliminate rows BEFORE the like clause gets
evaluated....

Eric



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.