Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread External module speed
Wed, Mar 12 2008 3:38 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

While messing yesterday I did a test between using an external module and using sql.

The sql was SELECT * FROM Sites WHERE REPLACE(' ','',_Switchboard) = REPLACE(' ','','01293 587369')

This took c .03 secs

The external module

function SpacelessCompare(const FldStr, CompStr: string): boolean;
begin
Result := StringReplace(FldStr, ' ', '', [rfReplaceAll]) = StringReplace(CompStr, ' ', '', [rfReplaceAll]);
end;

SELECT * FROM Sites WHERE SpacelessCompare(_Switchboard,'01293 587369')

took c.3 secs ie 10 times longer

Sites has 9327 rows and an index on _Switchboard so I'm guessing that its the index that make the difference - index scan vs row scan. Is that a good guess?

Roy Lambert

Wed, Mar 12 2008 3:41 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< took c.3 secs ie 10 times longer

Sites has 9327 rows and an index on _Switchboard so I'm guessing that its
the index that make the difference - index scan vs row scan. Is that a good
guess? >>

No, the time is most likely simply down to the shuttling of the parameters
back and forth to the external module.  There's a bit of overhead associated
with this, which is why we recommend only using external modules for
functions/procedures that aren't going to be called frequently, and using
SQL/PSM for functions that will be called frequently.

If you run both queries with an execution plan, you'll see that both use row
scans.

--
Tim Young
Elevate Software
www.elevatesoft.com

Thu, Mar 13 2008 5:00 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

>If you run both queries with an execution plan, you'll see that both use row
>scans.

Should have thought of that Frown

Roy Lambert
Image