Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Query can not be optimized?
Message
From
03/10/2006 06:12:48
Thomas Ganss (Online)
Main Trend
Frankfurt, Germany
 
 
To
02/10/2006 11:23:40
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01158559
Message ID:
01158808
Views:
24
>
>select *;
>  from person p
> inner join referral r on p.cl_ref = r.cl_ref and !empty(r.re_date);
>      where gomonth(p.cl_dob, 216) > (select min(rr.re_date) from referral rr;
>                                             where rr.cl_ref = p.cl_ref and !empty(rr.re_date))
>
>
>According to Fox none of this is optimised, both cl_ref fields on each table are indexed.
>
>Can anyone suggest an alternative that may be quicker - or is there anything else I could do to speed up the query?

Sys(3054) has to be interpreted carefully <g>.
You probabably would get rushmore optimized filtering if you had an index on
r.re_date and switched to r.re_date<>{..} as empty is not rushmore-optimizable.
***WARNING*** Having sys(3054) state that the the table is optimized can actually be working slower if none or very few records are cought by that filter, especially if the table sits on another machine. Check the selectivity of such an index FIRST!

INdexing on "gomonth(p.cl_dob, 216)" or "cl_dob *and* moving the calculation into the select" are probably better for speeding up your query. Experiment <g>.

the index on cl_ref should be used, but will probably shown in the sys(3054)-line as used by the join, not by rushmore.

HTH

thomas
Previous
Reply
Map
View

Click here to load this message in the networking platform