Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7493851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:12:29+00:00 2026-05-29T17:12:29+00:00

I have a big xml database (30 000 files, 1.3 Go). One file in

  • 0

I have a big xml database (30 000 files, 1.3 Go). One file in this database lists all the other files present in the database. My aim is “simply” to check if all files listed are present in the database. BUT I must not take care of the name of the files but only the XML code inside the documents.

This is something like that :

declare variable $root :=  fn:collection();

declare function local:isValid($fileCode) {

let $fileSearchedIdentCode := $root/dmodule/identity/dmCode
return 
$fileCode/@attribute1 = $fileSearchedIdentCode/@attribute1 and
$fileCode/@attribute2 = $fileSearchedIdentCode/@attribute2 and
$fileCode/@attribute3 = $fileSearchedIdentCode/@attribute3

};

<result>
{ 
for $fileCode in $root/file[identity/@fileType eq 'listOfFiles']/fileContent/fileEntry/fileCode 
return
    if (local:isValid($fileCode))
    then   <filePresent>1</filePresent>  
    else <fileNonPresent>2</fileNonPresent>

}
</result>

The code above is running for a small databse but for mine, it is requiring a incredible amount of time.

SO, I wonder if someone can help me to improve that code in order to execute it in a reasonable time 😉

(My database is indexed)

Thanks for your help !!

Johann

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T17:12:36+00:00Added an answer on May 29, 2026 at 5:12 pm

    It seems that the Attribute Index isn’t applied to the attribute checks in the local:isValid function. You can achieve that by rewriting them as XPath predicates:

    declare variable $root :=  fn:collection();
    
    declare function local:isValid($fileCode) {
      $root/dmodule/identity/dmCode[@attribute1 = $fileCode/@attribute1
        and @attribute2 = $fileCode/@attribute2
        and @attribute3 = $fileCode/@attribute3]
    };
    
    <result> { 
      for $fileCode in $root/file[identity/@fileType = 'listOfFiles']/fileContent/fileEntry/fileCode 
      return
        if (local:isValid($fileCode))
          then   <filePresent>1</filePresent>  
          else <fileNonPresent>2</fileNonPresent>
    }</result>
    

    After these changes, the Query Info view in BaseX tells me that the index is used:

    Compiling:
    - pre-evaluating fn:collection()
    - rewriting And expression to predicate(s)
    - rewriting fn:boolean(@*:attribute1 = $fileCode/@attribute1)
    - rewriting fn:boolean(@*:attribute2 = $fileCode/@attribute2)
    - rewriting fn:boolean(@*:attribute3 = $fileCode/@attribute3)
    - applying attribute index
    - applying attribute index
    

    and the evaluation time drops from 4’500ms to ~20ms for my test data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this very huge XML file of size 2.8GB. This is Polish Wikipedia's
I have a big XML file the setup my application. There are a lot
I have a big xml file (>300 mb), I am using notepad++ to find
I have a big xml file and parsing it consumes a lot of memory.
Background: I have one Access database (.mdb) file, with half a dozen tables in
I have a big (1.9 GB) XML file which has data I want to
I have a WCF application that at present is using XML based file storage
We have pretty big (~200mb) xml files from different sources that we want to
I have a big stack of XML files with different schemas. Many of the
I have loop, where I'll copy all *.txt files to big.txt in the same

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.