Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread Faster way to delete without SQL
Wed, Jan 24 2018 3:56 AMPermanent Link

Jose Eduardo Helminsky

HPro Informatica

Which is faster:

Table.SetRange([<start>],[<end]>]);  // <start> and <end> are the same
Table.First;
while not Table.Eof do begin
  Table.Delete;
end;

or

while Table.FindKey([<key>]) do begin
  Table.Delete;
end;

Thanks in advance
Eduardo
Wed, Jan 24 2018 4:50 AMPermanent Link

Jose Eduardo Helminsky

HPro Informatica

Sorry about my English

The correct question should be:

The fastest way...
Wed, Jan 24 2018 5:46 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Jose


The correct answer is .... SQL (probably)

It really depends on a number of factors - table size, layout and organisation, wether the table is connected to visual controls or not.

SQL -

DELETE FROM table WHERE field BETWEEN ninvalue AND maxvalue



Roy Lambert
Wed, Jan 24 2018 6:22 AMPermanent Link

Jose Eduardo Helminsky

HPro Informatica

Roy

I know SQL is the fastest way.

My question is about of know the overhead of SetRange + While x FindKey.

I think Tim is the person that will answer it with sure but my opinion is the method with FindKey is the fastest way

Eduardo
Wed, Jan 24 2018 7:58 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Jose

>My question is about of know the overhead of SetRange + While x FindKey.

>I think Tim is the person that will answer it with sure but my opinion is the method with FindKey is the fastest way

Slightly different question, and my money would be on SetRange. My logic goes

FindKey has to traverse the index for every deletion, SetRange essentially creates a filter and then you're just moving through the filter picking up the next each time. I'm not sure if the filter would be regenerated after each delete which could have a major impact.

Being insatiably curious is there a reason for the question or is it just curiosity?

Roy
Wed, Jan 24 2018 8:11 AMPermanent Link

Jose Eduardo Helminsky

HPro Informatica

Roy Lambert wrote:

<<
Being insatiably curious is there a reason for the question or is it just curiosity?
>>

It is just curiosity.

Eduardo
Fri, Jan 26 2018 12:24 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Eduardo,

<< Which is faster: >>

The SetRange version is slightly faster because DBISAM doesn't need to traverse the (relatively shallow) depth of the index tree every time for the FindKey operation.  Rather, it just tests index keys against the bounds of the range when navigating the leaf nodes of the index tree.

Tim Young
Elevate Software
www.elevatesoft.com
Image