We help IT Professionals succeed at work.

speeding dbf queries results .net (cdx?)

infogws
infogws asked
on
Medium Priority
748 Views
Last Modified: 2012-05-11
Hi, I need to optimize a query in FoxPro 2.6 that I'm running from a dataset in visual studio 2008 the query is posted below.

I've been provided with cdx index files and been told they can help me speed up the query results, any ideas?


SELECT geprevis.contrato, geprevis.codsoc, ccsocios.sonombre, ccsocios.soapelli, ccsocios.sosexo, ccsocios.sofecnac, ccsocios.soestciv, ccsocios.sodirecc,
                          ccsocios.sodistrito, ccsocios.sotelefo, ccsocios.socelu, ccsocios.somail, ccsocios.solibele, ccsocios.soocupa, ccsocios.socentra
FROM geprevis, ccsocios
WHERE (geprevis.codsoc = ccsocios.socodsoc) AND (geprevis.contrato LIKE 'S% ') AND (ccsocios.soapelli LIKE? + '% ') OR
                          (ccsocios.sonombre =? + '% ')

Open in new window

Comment
Watch Question

Author

Commented:

it takes about 10-15 minutes to search among 65000 records...
Carlos VillegasFull Stack .NET Developer

Commented:
Hi buddy, I think that you must check your table indexes. How many rows have those tables?

Author

Commented:
I've never worked with cdx files before to be honest.
Rows or columns? ccsocios has more than 20 rows, but I only need around 10.
I need to make a query to two tables at the same time.(geprevis and ccsocios).

When I only use one parameter it takes no longer than 3-5 seconds. When using 2 parameters it takes between 10-15, sometimes more (up to 20).

Author

Commented:
I've never worked with cdx files before to be honest.
Rows or columns? ccsocios has more than 20 columns, but I only need around 13.
I need to make a query to two tables at the same time.(geprevis and ccsocios).

When I only use one parameter it takes no longer than 3-5 seconds. When using 2 parameters it takes between 10-15, sometimes more (up to 20).
the slow speed is because of the where clause, if you using non-indexed fields in where clause foxpro will take a long time to return the query, can you set the fields in where clause as index fields? is it an option for you or you can't change database?
alternatively, you can bring all the data in without 'where' then sort them later on by codes.

Author

Commented:
I cant alter the dbf/cdx files. The database is currently used by another (older) system.
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT

Commented:
You should also check the OLE DB driver version. The possibility to partially optimize LIKE operator is included in the latest version only.
Olaf DoschkeSoftware Developer
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Thanks for your ideas
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.