Sem_match query

Is it possible to use the sem_match query in java like a normal sql query?

Yes. You should be able to execute a SQL SEM_MATCH query directly in Java using JDBC.

Similar Messages

  • SEM_MATCH query failed: ORA-06502: PL/SQL: numeric or value error: characte

    I use sqlplus to run a query statement with the SEM_MATCH function, and got the following error:
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-06512: at "MDSYS.RDF_MATCH_IMPL_T", line 176
    ORA-06512: at line 1
    Could it be a bug in the MDSYS.RDF_MATCH_IMPLE_T? I find the MDSYS.RDF_MATCH_IMPL_T in Oracle SQL Developer, but the code is not readable.
    Thanks.

    It is not likely to be a bug, but an issue of how SEM_MATCH is used. It would be best to contact Oracle Support with your sample SEM_MATCH query that causes the error.
    Melli

  • SEM_MATCH query execution time when a predicate is set as a variable

    Hello there,
    Our ontology contains 70 million triples (12.5 million asserted triples and 58 million inferred triples). We created a virtual model which includes both asserted and inferred triples).
    Our semantic network index configuration is 'PSCM' (index status is valid).
    The problem we encounter is when we run a SEM_MATCH query which includes a predicate as a variable, the query ran for 22 seconds. When a similar query is run when the variable is subject or an object or both the time for the SEM_MATCH query execution is 0.2 seconds. Is this reasonable? What do we do wrong?
    For example:
    1. Predicate as a variable (execution time is 22 seconds):
    SELECT a FROM TABLE ( SEM_MATCH
    ( ' { <http://www.tomproj.com/rep#entity_4> ?a 4 }',
    SEM_MODELS( 'TOM_VIRTUAL_MODEL') ,
    NULL,
    NULL,
    NULL,
    'ALLOW_DUP=T'));
    2. Subject as a variable (execution time is 0.2 seconds):
    SELECT a FROM TABLE ( SEM_MATCH
    ( ' { ?a <http://www.tomproj.com/rep#id> 4  }',
    SEM_MODELS( 'TOM_VIRTUAL_MODEL') ,
    NULL,
    NULL,
    NULL,
    'ALLOW_DUP=T'));
    2. Object as a variable (execution time is 0.2 seconds):
    SELECT a FROM TABLE ( SEM_MATCH
    ( ' { <http://www.tomproj.com/rep/#entity_4> <http://www.tomproj.com/rep#id> a }',
    SEM_MODELS( 'TOM_VIRTUAL_MODEL') ,
    NULL,
    NULL,
    NULL,
    'ALLOW_DUP=T'));
    Cheers,
    Doron

    Hi,
    So far no lack, None of the solutions are working.
    Query execution time didn't change after executing the following:
    1. SEM_APIS.DROP_SEM_INDEX('SCP');
    2. SEM_APIS.ADD_SEM_INDEX('SCPM');
    3. SEM_APIS.ALTER_SEM_INDEX_ON_MODEL('TOM','SCPM','REBUILD');
    4. SEM_APIS.ALTER_SEM_INDEX_ON_MODEL('TOM_TF','SCPM','REBUILD');
    5. SEM_APIS.ALTER_SEM_INDEX_ON_RULES_INDEX('TOM_RI','SCPM','REBUILD');
    My original query (see below) execution time remains 22 secs.
    SELECT a FROM TABLE ( SEM_MATCH
    ( ' { <http://www.tomproj.com/rep#entity_4> ?a 4 }',
    SEM_MODELS( 'TOM_VIRTUAL_MODEL') ,
    NULL,
    NULL,
    NULL,
    'ALLOW_DUP=T'));
    When running the SEM_MATCH on each model ('TOM,'TOM_TF') separately execution time was very fast (~0.007 secs):
    1. SELECT a FROM TABLE ( SEM_MATCH
    ( ' { <http://www.tomproj.com/rep#entity_4> ?a 4 }',
    SEM_MODELS( 'TOM') ,
    NULL,
    NULL,
    NULL,
    NULL));
    2. . SELECT a FROM TABLE ( SEM_MATCH
    ( ' { <http://www.tomproj.com/rep#entity_4> ?a 4 }',
    SEM_MODELS( 'TOM_TF') ,
    NULL,
    NULL,
    NULL,
    NULL));
    When running the query on both models, execution time was 54 secs:
    SELECT a FROM TABLE ( SEM_MATCH
    ( ' { <http://www.tomproj.com/rep#entity_4> ?a 4 }',
    SEM_MODELS( 'TOM','TOM_TF') ,
    NULL,
    NULL,
    NULL,
    NULL));
    We also run the original query via the Jena Adaptor using Java language and SPARQL, but the results were similar.
    As for using parallel parameter in SEM_APIS.ALTER_SEM_INDEX…, since we are using Oracle 11g release 1 the SEM_APIS.ALTER_SEM_INDEX doesn’t support the parallel parameter as far as we know.
    In Oracle 11g release 2 the SEM_APIS.ALTER_SEM_INDEX was extended to support the use of 'parallel' parameter.
    Any ideas on what do we do wrong?
    Cheers,
    Doron

  • Missing triples in SEM_MATCH query

    Hi,
    After loading the LUBM50,0 test data into Oracle 11g and running the sample queries I found some very strange behavior:
    Test query 14 for example returns 0 results (should be 393730 result sets - no inferencing is needed).
    Most queries work as expected, however in some cases data is not returned from SEM_MATCH (I was not yet able to figure out what really causes this behavior).
    This is what I did:
    Using Oracle 11gR1 (11.1.0.6.0) on Windows XP
    Load the test data (LUBM 50,0) via sqlldr to staging table and bulk load from there to the table used in the semantic model.
    The following query produces 0 results:
    select x from
         table (sem_match('(?x rdf:type ub:UndergraduateStudent)',
         sem_models('lubm'),
         null,
         sem_aliases(sem_alias('ub','http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#')), null));
    However, the data is actually contained in the table holding the SDO_RDF_TRIPLE_S.
    A query for all triples using SEM_MATCH also returns triples that satisfy this query and should be returned. (Query using '(?o ?p ?s)').
    By querying the table containing the semantic references directly also the correct results are returned.
    More strangely a query using sem_match like the one above querying for an object of "ub:GraduateStudent" instead of "ub:UndergraduateStudent" also returns (the correct) results.
    Moreover, the bulk load contains 6,890,946 triples which is the number of triples contained in the staging table and after bulk loading from there exactly this number is also contained in the table for the semantic model.
    However, the query using SEM_MATCH (unrestricted query of '(?o ?p ?s)') which should also return this number of triples only returns 6,657,233 triples (I have not yet checked which triples are missing, but there are more than 200,000 triples gone)
    Is there any hint on what I might be doing wrong or how to solve this problem?
    Thanks,
    Wolfgang

    Wolfgang,
    I'd suggest downloading the latest patch for 11g (links are posted by Melli in the following thread: Latest Patches for Oracle as suggested by TopBraid and then re-loading and then re-trying the query. Please let us know if that solves the problem.
    Thanks,
    - Souri.

  • How to sem_match query on "more than one"

    Here is graph,
    <Subject A> <:relate> <Object B>
    <Subject A> <:relate>  <Object C>
    I want to find all the subject nodes which relate more than one objects, if using sem_match SQL query, how to represent the match pattern?
    Thanks.

    We can use an aggregate for that.
    SELECT ?subj
    WHERE
    { ?subj :relate ?obj }
    GROUP BY ?subj
    HAVING (COUNT(*) > 5)
    With this strategy we don't have to worry about duplicate objects because we aren't doing a join.
    You can replace 5 with whatever number of :relates you need.

  • Oracle Jena Plugin and "?Resource" in select

    If I execute a SPARQL query like below:
    SELECT ?Resource where { ?Resource ?p ?o .}
    In Jena, it generates the following SEM_MATCH query that results in an error:
    (SimpleLog.java:57) - Final clause = SELECT Resource$RDFVTYP, decode(Resource$RDFVTYP, 'BLN', ('_:'||substr(Resource,instr(Resource,'m',4)+1)), Resource) Resource FROM table(sdo_rdf_match('(?Resource ?p ?o) ', sdo_rdf_models('model_name_here'), null, null, null, NULL,' '))
    which results in a ORA-00936: missing expression.
    If I change the select statement to something like ?Res rather than ?Resource, a proper statement is generated and I get no error. Is resource a reserved keyword or something? Are there a list of these somewhere?
    Thanks,
    Ryan

    So no PL/SQL keyword can appear in the select clause of a SPARQL statement? Shouldn't the code that translates a SPARQL statement into a SEM_MATCH statement just change that into a valid string? I'm not writing the PL/SQL statement, the Oracle Jena plugin is the one creating the improper statement.
    -Ryan

  • Java- PreparedStatement Vs Jena-QueryExecutionFactory/QueryFactory

    PreparedStatement pstmt = connection.prepareStatement(sqlString);
    Vs
    QueryExecution qe = QueryExecutionFactory.create(SPARQL_QUERY, model);
    Which is better in performance PreparedStatement or QueryExecutionFactory? As there is no class called
    PreparedStatement in Jena. I mean we have sqlstatement as precompiled when we used PreparedStatement in java,
    is it same with Jena?

    Hi Zhe,
    Say i use Same query and run it using.
    1. JDBC PreparedStatement creating a SEM_MATCH query
    2. Jena API creating SPARQL query
    Where in both cases query is same but created in a different way (using 1.SEM_MATCH and 2. SPARQL)
    So which will give better performance?
    Thanks and Regards,
    Manish Hardasmalani

  • Partitioning on CREATE_RDF_MODEL

    Hi,
    How to apply the partition table within CREATE_RDF_MODEL?
    If possible please provide me the syntax.
    Regards,
    Kavitha.

    Hi,
    A SEM_MATCH / SPARQL query does not access the application table (TST_SMA_CURR_RDF_PTN in your example). Instead, a SEM_MATCH query accesses the MDSYS.RDF_VALUE$ and MDSYS.RDF_LINK$ system tables. These system tables are partitioned so that each semantic model is one partition in MDSYS.RDF_LINK$.
    The application table is used for DML operations on a semantic model. The application table is not used during SPARQL query execution (the only exception is for named graph queries with Sesame adapter), so any partitioning on the application table will have no effect on SEM_MATCH query execution. It is therefore not possible to specify a partition from the application table in a SEM_MATCH / SPARQL query.
    If you want to partition your semantic data in a certain way, you could create one model for each desired partition. For example,
    CREATE TABLE TST_SMA_CURR_RDF_PTN1
    (ID NUMBER, TS NUMBER, TRIPLE MDSYS.SDO_RDF_TRIPLE_S);
    CREATE TABLE TST_SMA_CURR_RDF_PTN2
    (ID NUMBER, TS NUMBER, TRIPLE MDSYS.SDO_RDF_TRIPLE_S);
    CREATE TABLE TST_SMA_CURR_RDF_PTN3
    (ID NUMBER, TS NUMBER, TRIPLE MDSYS.SDO_RDF_TRIPLE_S);
    EXECUTE SEM_APIS.CREATE_RDF_MODEL('TST_SMA_PTN1_MDL', 'TST_SMA_CURR_RDF_PTN1', 'triple');
    EXECUTE SEM_APIS.CREATE_RDF_MODEL('TST_SMA_PTN2_MDL', 'TST_SMA_CURR_RDF_PTN2', 'triple');
    EXECUTE SEM_APIS.CREATE_RDF_MODEL('TST_SMA_PTN3_MDL', 'TST_SMA_CURR_RDF_PTN3', 'triple');
    INSERT INTO TST_SMA_CURR_RDF_PTN1 VALUES (1,23,
    SDO_RDF_TRIPLE_S ('TST_SMA_PTN1_MDL','http://nature.example.com/Article1',
    'http://purl.org/dc/elements/1.1/title','All about XYZ'));
    INSERT INTO TST_SMA_CURR_RDF_PTN2 VALUES (2,24,
    SDO_RDF_TRIPLE_S ('TST_SMA_PTN2_MDL','http://nature.example.com/Article1',
    'http://purl.org/dc/elements/1.1/creator',
    'Jane Smith'));
    INSERT INTO TST_SMA_CURR_RDF_PTN3 VALUES (3,25,
    SDO_RDF_TRIPLE_S ('TST_SMA_PTN3_MDL','http://nature.example.com/Article1',
    'http://purl.org/dc/elements/1.1/creator',
    'Jane Smith'));
    INSERT INTO TST_SMA_CURR_RDF_PTN1 VALUES (4,26,
    SDO_RDF_TRIPLE_S ('TST_SMA_PTN1_MDL','http://nature.example.com/Article1',
    'http://purl.org/dc/elements/1.1/creator',
    'Jane Smith'));
    Then you could query the TST_SMA_PTN3_MDL semantic model to access the third partition.
    SELECT s1 , s2 , s3
    FROM TABLE
    (sem_match
    ('(?s1 ?s2 ?s3)',
    sem_models ('TST_SMA_PTN3_MDL'),
    NULL,
    Null,
    Null
    ORDER BY s1, s2;
    Thanks,
    Matt

  • How to use SEM_RELATED & SEM_MATCH in a single query

    Hi,
    I am trying to combine RDF and RDBMS data using SEM_RELATED.
    Below sample is working fine but the requirement is i have to add few more conditions in SEM_MATCH
    Please suggest me how to combine sem_match and sem_related in a single query.
    Please provide me the example which use SEM_MATCH and SEM_RELATED in a single query.
    SELECT distinct dg_term_property.CONTEXT_NM FROM dg_term_property,dg_term
    WHERE SEM_RELATED ('<http://www.cs.com/mdm/data_glossary#Facilities>',
    '<http://www.w3.org/2000/01/rdf-schema#subClassOf>',
    '<http://www.cs.com/mdm/data_glossary#Reference_Data_Classes>',
    sem_models('GSR_PR_CURR'), sem_rulebases('owlprime')) = 1
    and DG_TERM.TERM_NM=DG_TERM_PROPERTY.TERM_NM;
    Let me know if you need any other details.
    Regards,
    Kavitha.

    Hi Kavitha,
    I am not sure what exactly you are trying to accomplish with this query but the use of the SEM_RELATED is incorrect. To fulfill your requirement most likely you may not even need to combine SEM_RELATED with SEM_MATCH. Actually those two are not built to be used together.
    Take a look at the SEM_RELATED documentation and see if you can use it to get the results you need. The example that you are providing is not using the SEM_RELATED correctly.
    Here is the documentation:
    http://docs.oracle.com/cd/E11882_01/appdev.112/e25609/owl_concepts.htm#CHDJBGFI
    Go to:
    2.3 Using Semantic Operators to Query Relational Data
    Regards!
    Jorge
    Edited by: jbarba on Aug 20, 2012 10:20 AM
    Edited by: jbarba on Aug 20, 2012 10:21 AM

  • How to obtain the transformed SQL query using SEM_MATCH

    Dear all,
    Is it possible to get the transformed relational SQL query when using the SEM_MATCH prefix, by querying directly on the database. We are able to obtain the relational SQL query using Joseki/Jena, however this is not the way to go for us. We would like (if possible) to get it straight from the oracle database by logging or something.
    Kind regards.
    Max

    Hi Max,
    Just to clarify. What SEM_MATCH prefix are you talking about?
    A SEM_MATCH based query is indeed a SQL query as SEM_MATCH is a SQL table function. So if you don't want to go through Java APIs or web service endpoint, then running SEM_MATCH directly should give you what you need. Or maybe you just want to see the underlying generated (from SEM_MATCH) SQL query. If that is true, can you please tell us why?
    Thanks,
    Zhe Wu

  • How to create a normal view from the RDF sparql query?

    Hi,
    I am trying to create a view from the below query.
    select id, name from table(SEM_MATCH('
    (?id rdf:type dm:Conceptual_SMA_Information_Group)
    (?id dm:hasConceptualSmaInformationGroupName ?name)',
    SEM_Models('nyc_sma_curr'), null,
    SEM_ALIASES(SEM_ALIAS('dm','http://www.cdse.com/sbip/dwh/mdm/data_modeling#')), null))
    order by name,id;
    I am trying the below syntax to create a viewa but its giving the error and m unable to create view.
    create view Information_Group as
    select id, name from table(SEM_MATCH('
    (?id rdf:type dm:Conceptual_SMA_Information_Group)
    (?id dm:hasConceptualSmaInformationGroupName ?name)',
    SEM_Models('nyc_sma_curr'), null,
    SEM_ALIASES(SEM_ALIAS('dm','http://www.cdse.com/sbip/dwh/mdm/data_modeling#')), null))
    order by name,id;
    Error: ORA-00600: internal error code, arguments: [17046], [0x46E62D720], [0x46F2485F0], [1], [], [], [], [], [], [], [], []
    Please help me to create a view.
    Let me know if you need more details.
    Regards,
    Kavitha.

    Hi,
    This is a known issue in 11.1 (RDBMS Bug 6688356).
    Please contact Oracle Support to get the patch for this bug. Alternatively, you can upgrade to release 11.2.
    Thanks,
    Matt

  • Error while trying to use '{' in the query

    Hi,
    The below mentioned query is giving Error while trying to use '{'
    Query:
    select s,x from table(SEM_MATCH(
    '{?s rdf:type <http://www.cs.com/sbip/dwh/mdm/data_modeling#Base_Term> .
    ?s ?p ?x}',
    SEM_Models('foundation'),
    SEM_RuleBases('OWLPRIME'),
    SEM_ALIASES(SEM_ALIAS('dm','http://www.cs.com/sbip/dwh/mdm/data_modeling#'),
    SEM_ALIAS('owl','http://www.w3.org/2002/07/owl#')), null, 'INVALID'))
    where regexp_like(x,'Customers','i');
    Error details:
    ORA-29532: Java call terminated by uncaught Java exception: oracle.spatial.rdf.server.TokenMgrError: Lexical error at line 1, column 1. Encountered: "{" (123), after : ""
    ORA-06512: at "MDSYS.RDF_MATCH_IMPL_T", line 178
    ORA-06512: at "MDSYS.RDF_MATCH_IMPL_T", line 67
    ORA-06512: at line 4
    I am unable to use Option, Filter in query.
    Any solution?
    Please let me know do i need to apply any patch?
    Note: I am using Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    Regards,
    Kavitha.

    Hi,
    For OPTIONAL support in 11.1.0.7.0, you need the following patch
    Patch 7600122: CURLY BRACE SYNTAX,VIRTUAL MODELS, NETWORK INDEXES AND HINTO FRAMEWORK SUPPORT
    Support for SPARQL FILTERs in SEM_MATCH is not available for 11.1.0.7.0. You will need version 11.2.0.1.0 or later for FILTER support. With 11.2.0.1.0, we recommend that you apply our latest patch set:
    Patch 9819833: SEMANTIC TECHNOLOGIES 11G R2 FIX BUNDLE 2
    All of the above patches are available through My Oracle Support.
    Thanks,
    Matt

  • Too long query

    Hello,
    I'm working on Oracle 11.2.0.3.
    I'm trying to execute this query
    SELECT distinct s, prefLabel,o
    FROM TABLE(SEM_MATCH('PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
    PREFIX orardf:<http://xmlns.oracle.com/rdf/>
    SELECT *
    WHERE
    ?s ?p ?o.
    ?s skos:prefLabel ?prefLabel .
    filter (lang(?prefLabel ) ="fr").
    filter (orardf:textContains(?prefLabel , "famille")).
    SEM_Models('modelinf'),
    SEM_Rulebases('SKOSCORE'),
    null,
    null,
    null,
    null ))
    but it takes too long time.
    I'm not sure that all the necessary index has been create on the database.
    Could you help me to optimize this query ?
    Thanks.
    Cyril.

    Hello,
    this is the execution plan of this query
    SELECT s, prefLabel
    FROM TABLE(SEM_MATCH('PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
    PREFIX orardf:<http://xmlns.oracle.com/rdf/>
    SELECT distinct ?s ?prefLabel
    WHERE
    ?s rdf:type skos:Concept.
    ?s skos:prefLabel ?prefLabel .
    filter (lang(?prefLabel ) ="fr").
    filter (orardf:textContains(?prefLabel , "famille")).
    SEM_Models('modelinf'),
    SEM_Rulebases('SKOSCORE'),
    null,
    null,
    null,
    null ))
    It takes 2.703 seconds for 12 rows
    Plan hash value: 1619577833
    | Id | Operation | Name | Pstart| Pstop |
    | 0 | SELECT STATEMENT | | | |
    | 1 | COLLECTION ITERATOR SUBQUERY FETCH | | | |
    | 2 | COUNT | | | |
    |* 3 | FILTER | | | |
    | 4 | NESTED LOOPS | | | |
    | 5 | NESTED LOOPS | | | |
    | 6 | VIEW | | | |
    | 7 | SORT GROUP BY | | | |
    | 8 | NESTED LOOPS | | | |
    | 9 | NESTED LOOPS | | | |
    | 10 | NESTED LOOPS | | | |
    | 11 | VIEW | | | |
    | 12 | UNION-ALL | | | |
    | 13 | PARTITION LIST SINGLE | | 3 | 3 |
    |* 14 | INDEX RANGE SCAN | RDF_LNK_PCS_IDX | 3 | 3 |
    | 15 | PARTITION LIST SINGLE | | 4 | 4 |
    |* 16 | INDEX RANGE SCAN | RDF_LNK_PCSGM_IDX | 4 | 4 |
    | 17 | VIEW | | | |
    | 18 | UNION-ALL PARTITION | | | |
    | 19 | PARTITION LIST SINGLE | | 3 | 3 |
    |* 20 | INDEX RANGE SCAN | RDF_LNK_PSC_IDX | 3 | 3 |
    | 21 | PARTITION LIST SINGLE | | 4 | 4 |
    |* 22 | INDEX RANGE SCAN | RDF_LNK_PSCGM_IDX | 4 | 4 |
    |* 23 | INDEX UNIQUE SCAN | C_PK_VID | | |
    |* 24 | TABLE ACCESS BY INDEX ROWID| RDF_VALUE$ | | |
    |* 25 | INDEX UNIQUE SCAN | C_PK_VID | | |
    | 26 | TABLE ACCESS BY INDEX ROWID | RDF_VALUE$ | | |
    |* 27 | TABLE ACCESS FULL | RDF_RI_SHAD_5$ | | |
    Predicate Information (identified by operation id):
    3 - filter( NOT EXISTS (SELECT 0 FROM "MDSYS"."RDF_RI_SHAD_5$"
    "RDF_RI_SHAD_5$" WHERE LNNVL("RDF_RI_SHAD_5$"."ID"<>1)))
    14 - access("P_VALUE_ID"=834132227519661324 AND
    "CANON_END_NODE_ID"=8129753520990573772 AND "START_NODE_ID">0 AND
    "START_NODE_ID" IS NOT NULL)
    16 - access("P_VALUE_ID"=834132227519661324 AND
    "CANON_END_NODE_ID"=8129753520990573772 AND "START_NODE_ID">0 AND
    "START_NODE_ID" IS NOT NULL)
    20 - access("P_VALUE_ID"=8569708817671647133 AND
    "START_NODE_ID"="from$_subquery$_007"."START_NODE_ID" AND
    "CANON_END_NODE_ID">0 AND "CANON_END_NODE_ID" IS NOT NULL)
    filter("START_NODE_ID">0)
    22 - access("P_VALUE_ID"=8569708817671647133 AND
    "START_NODE_ID"="from$_subquery$_007"."START_NODE_ID" AND
    "CANON_END_NODE_ID">0 AND "CANON_END_NODE_ID" IS NOT NULL)
    filter("START_NODE_ID">0)
    23 - access("V0"."VALUE_ID"="from$_subquery$_011"."CANON_END_NODE_ID")
    24 - filter("SEM_APIS"."GETV$LANGVAL"("V0"."VALUE_TYPE","V0"."VNAME_PRE
    FIX","V0"."VNAME_SUFFIX","V0"."LITERAL_TYPE","V0"."LANGUAGE_TYPE")='fr'
    AND "CTXSYS"."CONTAINS"("V0"."VNAME_PREFIX",'famille'||'')>0)
    25 - access("R"."S$RDFVID"="V0"."VALUE_ID")
    27 - filter(LNNVL("RDF_RI_SHAD_5$"."ID"<>1))
    Thanks.
    Cyril

  • IS BIND() & COALESCE() supported in SEM_MATCH and if not what's alternative?

    I want to get rid of all these UNIONs and USE virtual model VISION instead of all these models: COMPASS, PROCESS, LIMS_ANALYTIC, CLOVER in SEM_MODEL() function...
    Jena:       VERSION: 2.11.1
    ARQ:       VERSION: 2.11.1
    RIOT:       VERSION: 2.11.1
    I know the query is large but I am trying to simplify it because it takes FOREVER!!
    SELECT DOMAIN, AGE_OF_DATA FROM
      SELECT Domain, max(protDate) as age_of_data FROM
      SELECT DOMAIN$_SUFFIX AS Domain, protNum, NVL(protStartDate, protCreateDate) AS protDate
      FROM TABLE(SEM_MATCH(
       ?ipc rdf:type s:Protocol .
       ?ipc s:hasDataSource :COMPASS .
       ?ipc s:protocolNumber ?protNum .
       ?ipc s:protocolCreateDate ?protCreateDate .
       OPTIONAL {?ipc s:protocolSchedStartDate ?protStartDate }
    *******BIND(COALESCE(?protCreateDate, ?protStartDate) AS ?age_of_data)  ***** <== can I use that instead of NVL() function above?
       ?ipd rdf:type s:Protocol .
       ?ipd s:hasDataSource ?domain .
       ?ipd s:protocolNumber ?protNum .
        }',SEM_Models('COMPASS','EDHRD','CLOVER'),NULL,
        SEM_ALIASES(SEM_ALIAS('','http://VISION/Data/SEMANTIC#'),SEM_ALIAS('s', 'http://VISION/DataSource/SEMANTIC#')),NULL,NULL,'ALLOW_DUP=T'))
       ORDER BY DOMAIN$_SUFFIX, protDate desc
        Group by Domain
       UNION
       SELECT 'LIMS_ANALYTICAL' as Domain, chgDate as age_of_data FROM
      SELECT chgDate
      FROM TABLE(SEM_MATCH(
       ?ipc rdf:type s:Test .
       ?ipc s:testChangeDate ?chgDate .
      }',SEM_Models('LIMS_ANALYTIC'),NULL,
      SEM_ALIASES(SEM_ALIAS('','http://VISION/Data/SEMANTIC#'),SEM_ALIAS('s',  'http://VISION/DataSource/SEMANTIC#')),NULL,NULL,'ALLOW_DUP=T'))
      ORDER BY chgDate desc
      WHERE ROWNUM = 1
       UNION
       SELECT process as Domain, substr(max(procEndDate),1,10) as age_of_data  FROM
      SELECT  process, protNum, procEndDate
      FROM TABLE(SEM_MATCH(
      ?ipra rdf:type s:ProcessAggregate .
      ?ipra s:hasProtocol ?iprot .
       ?iprot s:protocolNumber ?protNum .
      ?ipa    s:hasEquipment  ?iequ .
      ?iequ  s:pilotLineProcessName   ?process.
         ?ipra s:processAggregateCaptureTimeEnd ?procEndDate .
       }',SEM_Models('COMPASS','PROCESS'),NULL,
       SEM_ALIASES(SEM_ALIAS('','http://VISION/Data/SEMANTIC#'),SEM_ALIAS('s',  'http://VISION/DataSource/SEMANTIC#')),NULL,NULL,'ALLOW_DUP=T'))
       Group by process
        UNION
       select 'Tooling_Design'  as Domain, protocol_start_date as age_of_data
       from
       select protocol_start_date from mv_lot_detail l, mv_lot_design d
       where l.protocol_start_date is not null and l.fp_pr = d.fp_pr and l.bp_pr = d.bp_pr
       order by l.protocol_start_date desc
      Where rownum = 1

    I changed it so it looks better:
    SELECT DOMAIN, AGE_OF_DATA FROM
       SELECT CASE WHEN INSTR(Domain, '#') > 0 THEN SUBSTR(Domain, 29, INSTR(Domain, '#')-1)
              ELSE DOMAIN  END DOMAIN,
              SUBSTR(max(age_of_data), 1, 10) AGE_OF_DATA
        FROM
      SELECT domain_name AS Domain, protNum, NVL(protStartDate, age_of_data) AS age_of_data
      FROM TABLE(SEM_MATCH(
                         ?ipl   rdf:type s:Protocol .
                         ?ipl   s:hasDataSource :COMPASS .
                         ?ipl   s:protocolNumber ?protNum .
                         ?ipl   s:protocolCreateDate ?age_of_data .
                      OPTIONAL {?ipl s:protocolSchedStartDate ?protStartDate }
                         ?iec   rdf:type s:Protocol .
                         ?iec   s:hasDataSource ?domain_name .
                         ?iec   s:protocolNumber ?protNum .
                   UNION
                         ?pag   rdf:type         s:ProcessAggregate .
                         ?pag   s:hasProtocol    ?iprot .
                         ?iprot s:protocolNumber ?protNum .
                         ?pag   s:pilotLineProcessName   ?domain_name.
                         ?pag   s:processAggregateChangeDateTime ?age_of_data .
                   UNION
                         ?lim   rdf:type   s:Submission .
                         ?lim   s:hasDataSource  ?domain_name.
                         ?lim   s:submissionChangeDate ?age_of_data .
        }',SEM_Models('COMPASS','EDHRD', 'CLOVER', 'PROCESS', 'LIMS_ANALYTIC'),NULL,
        SEM_ALIASES(SEM_ALIAS('','http://VISION/Data/SEMANTIC#'),SEM_ALIAS('s', 'http://VISION/DataSource/SEMANTIC#')),NULL,NULL,'ALLOW_DUP=T'))
       ORDER BY domain_name
        Group by Domain
    UNION
       select 'Tooling_Design'  as Domain, max(protocol_start_date) age_of_data
            from semantic_read_only.mv_lot_detail l, semantic_read_only.mv_lot_design d
            where l.protocol_start_date is not null and l.fp_pr = d.fp_pr and l.bp_pr = d.bp_pr

  • SEM_MATCH performance

    I have a question regarding the performance of the SEM_MATCH function. When I execute the following query the performance of SEM_MATCH is very good as it is using the appropriate indexes to retrieve the data.
    select predicate, object
    FROM TABLE(SEM_MATCH('(<http://www.xyz.com/Student/100017> ?predicate ?object )',
    SEM_Models('students'),
    null,
    null,
    null))
    However, if I execute the following query, the performance is very bad as it is doing a full table scan on the MDSYS.RDF_LINK$ table.
    select subject, predicate, object
    FROM TABLE(SEM_MATCH(' (?subject ?predicate ?object )',
    SEM_Models('students'),
    null,
    null,
    null))
    where subject = 'http://www.xyz.com/Student/100017'
    I believe the reason for this is that the Table function must be resolved first, thus without any selection criteria in the SEM_MATCH function, a resulting full table scan is performed.
    Is there any way to resolve the outer part of the query first (subject = 'http://www.xyz.com/Student/100017' ) and project those results into the Table Function?
    Kevin

    if on 11.1.0.7, you could install patch 7600122, and then use the curly-brace syntax which just involves changing the pattern to
    ' {?subject ?predicate ?object } '
    Optionally, you could also use HINT0 as follows:
    (For more information, please see HINT0 related information in
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28397/sdo_rdf_concepts.htm#CHDJACII
    and
    curly-brace syntax related info in
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28397/sdo_rdf_concepts.htm#CIHEHAAD)
    select subject, predicate, object
    FROM TABLE(SEM_MATCH(' { ?subject ?predicate ?object } ',
    SEM_Models('students'),
    null,
    null,
    null
    ,null, ' HINT0 = { LEADING(?subject) } '
    where subject = 'http://www.xyz.com/Student/100017'
    ;

Maybe you are looking for