Cursor.FindSingleValue
Ivan Smahin
ivan_smahin at paradigmasoft.com
Tue Dec 29 01:08:26 CST 2009
Hello Thomas,
Monday, December 28, 2009, 10:23:11 PM, you wrote:
>> and then in cursor you can do binary search by that field values.
> what is "binary search by that field value" ?
The best and most natural way is to query only records you really need
in. It looks like you do something like "select * from table" and than
you are trying to apply another search criteria to the query result.
But you should do something like "select f1, f2 from t1 where f3 =
'value'" or something like this instead - I mean you should express your
search criteria inside the query.
Another way is creating some temporary table as a query result.
It would be probably helpful in case of long running queries
with complex search criteria. So later you could search a records in
that temporary table as you are trying to do with cursor.
One more note. Such problems may be result of poor database design.
One of the popular example is denormalization... In short ...
Assume you are developing some db schema for address book and you
decide to keep all properties in different tables linked all together
with some sort of link. So you will get something like People table,
Address table (linked to People table) and so on... Seems to be
correct... But finally you see that the only query you will run is -
get all properties for all men/women.
In our case it would be something like
SELECT * FROM tblPerson JOIN tblAddresses JOIN tblPhones JOIN....
WHERE fldGender = ...
But in this case probably it would be better to have a single table
with all that properties - yes it would be some repeatable records but
your query might be running faster than n-join-query...
To be more specific you should describe your needs more detailed.
--
Best regards,
Ivan Smahin
Senior Software Engineer
Paradigma Software, Inc
Valentina - The Ultra-Fast Database
http://www.valentina-db.com
More information about the Valentina
mailing list