comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Dataminer: faster way to get all records in a IDLdbRecordset table?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Dataminer: faster way to get all records in a IDLdbRecordset table? [message #36459 is a reply to message #36446] Wed, 17 September 2003 09:03 Go to previous messageGo to previous message
Dick Jackson is currently offline  Dick Jackson
Messages: 347
Registered: August 1998
Senior Member
Hi Tim,

"Tim Williams" <timothy.williams@nvl.army.mil> wrote in message
news:faf44c99.0309170738.ae75526@posting.google.com...
> I want to put the records in a database table into an IDL table
> widget. For fairly large tables, (> ~1500 rows), it's fairly slow and
> I get "Not responding" in the Task Manager for awhile while I'm
> getting each record. Here's what I'm doing now:
>
> ors=obj_new('IDLdbRecordset', table=tablename)
> status=ors->moveCursor(/first)
> if status eq 1 then begin
> rec=ors->getRecord()
> status=ors->moveCursor(/next)
> while (status eq 1) do begin
> rec=[rec, ors->getRecord()]
> status=ors->moveCursor(/next)
> end while
> endif
>
> Is there a faster way to get all of the records?

With that number of records, I think a lot of time may be in the
innocent-looking array concatenation:

rec=[rec, ors->getRecord()]

At the end, you're taking an array of 1498 records, creating a *new*
array with 1499 records and throwing out the old one. Lots of extra
memory copying here. My faster way is below (this would go within your
'if status eq 1' block, and you'll have to rework the variable names, of
course):

=====

;; Count how many records

nRecords = 0L
WHILE status NE 0 DO BEGIN
nRecords = nRecords+1
status = objRS -> MoveCursor(/Next)
ENDWHILE

;; Get structure from first record, replicate it

status = objRS -> MoveCursor(/First)
aRecord = objRS -> GetRecord()
result = Replicate(aRecord, nRecords)

FOR recordI=1, nRecords-1 DO IF status NE 0 THEN BEGIN
status = objRS -> MoveCursor(/Next)
IF status EQ 0 THEN $ ; Fewer records than when
counted above
result = result[0:recordI-1] $
ELSE result[recordI] = objRS -> GetRecord()
ENDIF

=====

Hope this helps!

Cheers,
--
-Dick

Dick Jackson / dick@d-jackson.com
D-Jackson Software Consulting / http://www.d-jackson.com
Calgary, Alberta, Canada / +1-403-242-7398 / Fax: 241-7392
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: lens distortion
Next Topic: Re: What does an optimal scientific programming language/environment need?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 07:22:56 PDT 2025

Total time taken to generate the page: 1.27892 seconds