Skip to content

XQuery: Optimizations on namespaced databases #1763

Open
@ChristianGruen

Description

@ChristianGruen

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions