Performance of matches() vs castable as xs:integer

Thursday, 3 April 2014 · 2 messages
HE
Hondros, Constantine (ELS-AMS)3 Apr 2014 17:32 #
Hello all, I'm scanning millions of XML records imported from CSV looking for instances of 'bib_rec_id' which are non-numeric. Which of these two is if-statements likely to complete earlier?
for $a in (/csv/record/bib_rec_id)
  return
    if ($a castable as xs:integer) then ... blah
or if (matches($a, '^[0-9]+$')) then ... blah Yes - I'm trying it out now, but I suspect it will be quicker to ask than wait for either query to complete. TIA. ________________________________ Elsevier B.V. Registered Office: Radarweg 29, 1043 NX Amsterdam, The Netherlands, Registration No. 33156677, Registered in The Netherlands.
DK
Dirk Kirsten3 Apr 2014 17:53 #
Hello Constantine, Why don't you try it out on a smaller subset (for $a in (/csv/record/bib_rec_id[position() < 1000)? My guess is the cast is faster, but when you try it you will now for sure. Cheers, Dirk
Quoted text · Constantine (ELS-AMS) · 29 lines
On 03/04/14 17:32, Hondros, Constantine (ELS-AMS) wrote: > Hello all, > > I'm scanning millions of XML records imported from CSV looking for instances of 'bib_rec_id' which are non-numeric. Which of these two is if-statements likely to complete earlier? > > for $a in (/csv/record/bib_rec_id) > return > if ($a castable as xs:integer) then ... blah > > or > > if (matches($a, '^[0-9]+$')) then ... blah > > > Yes - I'm trying it out now, but I suspect it will be quicker to ask than wait for either query to complete. > > TIA. > > ________________________________ > > Elsevier B.V. Registered Office: Radarweg 29, 1043 NX Amsterdam, The Netherlands, Registration No. 33156677, Registered in The Netherlands. > > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
-- Dirk Kirsten, BaseX GmbH, http://basex.org |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22

⚡Generated with XQuery