Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread FindLastKey
Mon, Sep 22 2014 8:48 AMPermanent Link

Jose Eduardo Helminsky

HPro Informatica

Sometimes I need to find the last key of a range of data.

Now, I have two ways for doing that

Create a descending index and use a FindKey

or

Apply SetRange and call Last

I donīt know how hard it is but if Tim can add a new method "FindLastKey" it will help a lot and we donīt need other index just to do so.

Well, my vote for this.
Mon, Sep 22 2014 9:28 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Jose


If its some sort of ascending key can't you use a query eg

SELECT MAX(key) FROM table WHERE info BETWEEN startofrange AND endofrange

Roy Lambert
Mon, Sep 22 2014 9:51 AMPermanent Link

Jose Eduardo Helminsky

HPro Informatica

Roy

The code you post works but in a intense processing this is not a good idea to call select a lot of times, findkey is faster than (very much) SQL. And the other thing is: I need the content of other fields in the record with the "max key".

Like I said there are other methods but maybe Tim can add this new method to dbisamtable. IMO, this will add speed for processing huge (some Gbytes) amount of data.

Thanks anyway for your contribution.
Mon, Sep 22 2014 1:00 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Jose

>The code you post works but in a intense processing this is not a good idea to call select a lot of times, findkey is faster than (very much) SQL. And the other thing is: I need the content of other fields in the record with the "max key".

I know that some table methods are faster than some sql but have you tried this with a parameterised and prepared query with the necessary indices in place?

>Like I said there are other methods but maybe Tim can add this new method to dbisamtable. IMO, this will add speed for processing huge (some Gbytes) amount of data.

Because you "simply" want the last key for a range then even Tim would have to do something such as SetRange or SELECT to get the value. If its an indexed field, and the range you talk about is on the index, then he should be able to use the index to get the info

Roy Lambert
Mon, Sep 22 2014 4:30 PMPermanent Link

Jose Eduardo Helminsky

HPro Informatica

Roy

<<
I know that some table methods are faster than some sql but have you tried this with a parameterised and prepared query with the necessary indices in place?
>>
Yes, but this is not the case. In my tests SetRange/Last is faster than prepared query.

<<
Because you "simply" want the last key for a range then even Tim would have to do something such as SetRange or SELECT to get the value. If its an indexed field, and the range you talk about is on the index, then he should be able to use the index to get the info
>>
I think you misunderstand my request. The idea here is other. The findkey use the binary tree index structure to move the record pointer. I donīt know DBISAM internally but my question is if there is a easy way to move the record pointer to the last key in the index three structure internally.

I donīt want to bother Tim if this is not easy. I have a table component inherited from DBISAM and for me it will be easy to create the method FindLastKey and put SetRange/Last idea but without performance impact.

Eduardo
Mon, Sep 22 2014 9:47 PMPermanent Link

Raul

Team Elevate Team Elevate

On 9/22/2014 4:30 PM, Jose Eduardo Helminsky wrote:
> I think you misunderstand my request. The idea here is other. The findkey use the binary tree index structure to move the record pointer. I donīt know DBISAM internally but my question is if there is a easy way to move the record pointer to the last key in the index three structure internally.
>
> I donīt want to bother Tim if this is not easy. I have a table component inherited from DBISAM and for me it will be easy to create the method FindLastKey and put SetRange/Last idea but without performance impact.

I went and looked at what FindKey does and while it does boil down do
calling the engine find function i'm not seeing anything obvious to
easily switch to finding the last instance (then again i'm no dbisam
source expert).

You'd have to email Tim/support direct to get an answer (and whether he
would even do it or if he thinks using existing range like you do is as
good as it gets). He does read these NGs but very rarely these days.

Raul
Image