Link to home
Start Free TrialLog in
Avatar of infogws
infogwsFlag for Peru

asked on

speeding dbf queries results .net (cdx?)

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

Avatar of infogws
infogws
Flag of Peru image

ASKER


it takes about 10-15 minutes to search among 65000 records...
Hi buddy, I think that you must check your table indexes. How many rows have those tables?
Avatar of infogws

ASKER

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).
Avatar of infogws

ASKER

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).
Avatar of miketonny
miketonny

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.
Avatar of infogws

ASKER

I cant alter the dbf/cdx files. The database is currently used by another (older) system.
SOLUTION
Avatar of miketonny
miketonny

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Pavel Celba
Pavel Celba
Flag of Czechia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You should also check the OLE DB driver version. The possibility to partially optimize LIKE operator is included in the latest version only.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of infogws

ASKER

Thanks for your ideas