Skip to Main Content

Berkeley DB Family

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

dateTime index query returning empty set - Berkeley DB XML 6.1.4

User_F8QRJApr 13 2022

I have schema conforming node documents with the following structure:

<ty:Detections xmlns:ty="http://tethys.sdsu.edu/schema/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <Id>SOCAL38M_fin_demo</Id> 
 </lots_of_other_stuff_removed>
 <Effort>
  <Start>2010-04-10T00:00:00Z</Start>
 </Effort>
</ty:Detections>

stored in Berkeley DB XML 6.1.4 running on Windows 10. I have set up indices for elements that are queried frequently and have a dateTime edge index on the Start element:

Index: edge-element-equality-dateTime for node {http://tethys.sdsu.edu/schema/1.0}:Start

Is there a specific way that XQueries should be written to take advantage of the index? The following query looks like it is using the index, but returns an empty result set.

declare default element namespace "http://tethys.sdsu.edu/schema/1.0";
for $det in collection("Detections")/Detections[Effort/Start >= xs:dateTime("2000-01-01T00:00:00Z")]
     return
        $det/Effort/Start

with query plan

<XQuery>
  <Return>
    <ForTuple name="{}det" position="">
      <ContextTuple/>
      <QueryPlanToAST>
        <LevelFilterQP>
          <StepQP axis="parent-of-child" uri="http://tethys.sdsu.edu/schema/1.0" localname="Detections" nodeType="element">
            <StepQP axis="parent-of-child" uri="http://tethys.sdsu.edu/schema/1.0" localname="Effort" nodeType="element">
              <ValueQP container="Detections" index="edge-element-equality-dateTime" operation="gte" parent="Effort:http://tethys.sdsu.edu/schema/1.0" child="Start:http://tethys.sdsu.edu/schema/1.0" value="2000-01-01T00:00:00Z"/>
            </StepQP>
          </StepQP>
        </LevelFilterQP>
      </QueryPlanToAST>
    </ForTuple>
    <QueryPlanToAST>
      <NodePredicateFilterQP name="{}#tmp21">
        <PresenceQP container="Detections" index="edge-element-equality-dateTime" operation="prefix" parent="Effort:http://tethys.sdsu.edu/schema/1.0" child="Start:http://tethys.sdsu.edu/schema/1.0"/>
        <ChildJoinQP>
          <VariableQP name="{}det"/>
          <StepQP axis="parent-of-child" uri="http://tethys.sdsu.edu/schema/1.0" localname="Effort" nodeType="element">
            <VariableQP name="{}#tmp21"/>
          </StepQP>
        </ChildJoinQP>
      </NodePredicateFilterQP>
    </QueryPlanToAST>
  </Return>
</XQuery>

I assume that this is a pilot error, are there any suggestions on how to resolve this? Leaving off the xs:dateTime results in a similar query plan.
Thank you - Marie

Comments

MartinBach-Oracle Jan 8 2025

Hi Salomon,

please have a look at this blog post written by @ulrike-schwinn-oracle :

https://blogs.oracle.com/coretec/post/easy-sql-statement-tracking-in23c

I hope this answers your question, if not, please shout!

- Martin

Solomon Yakobson Jan 8 2025

@martinbach-oracle - No, it doesn't answer my question. Article you pointed to shows uses:

SQL> alter system set sql_history_enabled=true scope=both;

And in my post I said “Works fine when enabled on system level”. My question was about

SQL> ALTER SESSION SET SQL_HISTORY_ENABLED = TRUE;

where I showed SQL history was NOT captured even though it should be based on SQL_HISTORY_ENABLED:

Modifiable **ALTER SESSION**, ALTER SYSTEM

SY.

MartinBach-Oracle Jan 8 2025

As per the article I shared the situation is as follows at the moment

  • You must enable SQL history PDB-wide (only a DBA can do that) so there's a certain level of control over the feature
  • Your session has access to the SQL history
  • If you don't want to record anything, set sql_history_enabled to false.

I'm currently assessing if that's intended behaviour (in which case the documentation should be amended) or a feature not working as it should (in which case it needs fixing). The parameter is indeed session-modifyable, but not in the sense you expected.

We'll keep you posted.

- Martin

Solomon Yakobson Jan 8 2025

Do you mean it must be enabled on system level and not on session level and all session can do is disabe it for the session?

SY.

MartinBach-Oracle Jan 14 2025

Yes,

that's correct as of Oracle Database Free 23.6.

- Martin

Solomon Yakobson Jan 14 2025

Thanks Martin, I hope this will be added to 23AI docs soon.

SY.

1 - 6

Post Details

Added on Apr 13 2022
0 comments
364 views