Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XQuery: Optimizations on namespaced databases #1763

Open
ChristianGruen opened this issue Nov 29, 2019 · 1 comment
Open

XQuery: Optimizations on namespaced databases #1763

ChristianGruen opened this issue Nov 29, 2019 · 1 comment
Labels

Comments

@ChristianGruen
Copy link
Member

ChristianGruen commented Nov 29, 2019

In the database storage of BaseX, element and attribute names are indexed by their prefix:local representation, and the namespace is retrieved at runtime. This is why some compile-time query optimizations are skipped if a database has namespaces.

There are cases, though, in which a more fine-grained namespace detection would be possible and desirable. For example, if a document only has non-default namespace declarations…

<a xmlns:pre='URI'><b>B</b></a>

…and if an element/attribute name in an XPath step has no namespace (e.g. //b), it can safely be associated with elements of the accessed database. Steps with non-existing elements can then be replaced with empty sequences, or a text() step can be attached to a path expression that may later be rewritten for index access.

Code: https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/query/util/index/IndexInfo.java#L83

Script:

create db simple <a xmlns:x='X'><b>B</b></a>
xquery /a[b = 'B']
close
@ChristianGruen ChristianGruen changed the title XQuery: optimization with namespaced databased XQuery: Optimizations on namespaced databases Nov 29, 2019
@ChristianGruen
Copy link
Member Author

ChristianGruen commented May 8, 2020

Related: If namespace detection is improved, . can be rewritten to text().

<commands>
  <create-db name='db'>
    <a xmlns='ns'>A</a>
  </create-db>
  <xquery>*:a[. = 'A']</xquery>
</commands>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant