Spatial query w/ logical operators in a subquery on Linux using Oracle 1

Hello...
I'm being given XML that I need to parse and create SQL from it. Below my signature is the SQL that I generate (its a simple example) and can be more elaborate due to the logical operators (AND and OR) given in the XML.
The problem that we're seeing is performance-based: when one of the logical operator queries is Spatial-based, like below. Running it in JDBC, the query never returns.
The spatial query just by itself returns ~300 rows (takes approximately 0.2 seconds). The "PERCENTAGE" query by itself returns about ~40000 rows (takes approximately ~.8 seconds).
If we run the query below with 2 non-spatial subqueries, the result returns and performance is very acceptable (~ 0.9 seconds)-- the result set is about 80000 rows.
Thanks,
Jim
=========================
SELECT
COLUMN_WE_WANT , RESULTS
FROM
TABLE_A
WHERE
COLUMN_WE_WANT IN
SELECT
COLUMN_WE_WANT
FROM
TABLE_A
WHERE
SDO_OVERLAPBDYINTERSECT(TABLE_A.MY_SPATIAL_COLUMN,
SDO_GEOMETRY(2003,
4326,
null,
SDO_elem_info_array( 1 , 3 , 1 ),
SDO_ORDINATE_ARRAY( lng_1,lat_1 , lng_2,lat_2 , lng_3,lat_3 , lng_4,lat_4 , lng_1,lat_1 )
) = 'TRUE'
OR
COLUMN_WE_WANT IN
SELECT
COLUMN_WE_WANT
FROM
TABLE_B
WHERE
SOME_PERCENTAGE_RATE_COLUMN < 90
)

Its difficult to comment without seeing the execution plan. You should trace this query to get a better idea of exactly what's happening.
Depending on the complexity of the logical operators, I would look at doing this using set operations. So for an OR you might have...
SELECT COLUMN_WE_WANT, RESULTS
FROM TABLE_A
WHERE COLUMN_WE_WANT IN (
     SELECT COLUMN_WE_WANT
     FROM TABLE_A
     WHERE SDO_OVERLAPBDYINTERSECT(TABLE_A.MY_SPATIAL_COLUMN,SDO_GEOMETRY(2003,4326,
     NULL, SDO_elem_info_array( 1 , 3 , 1 ),
     SDO_ORDINATE_ARRAY( lng_1,lat_1 , lng_2,lat_2 , lng_3,lat_3 , lng_4,lat_4 , lng_1,lat_1 ) )) = 'TRUE'
UNION
     SELECT COLUMN_WE_WANT
     FROM TABLE_B
     WHERE SOME_PERCENTAGE_RATE_COLUMN < 90)For an AND, you would use INTERSECT.
Edited by: Reggie to remove the extra INTERSECT

Similar Messages

  • Spatial query w/ logical operators in a subquery on Linux using Oracle 10g

    Hello...
    I'm being given XML that I need to parse and create SQL from it. Below my signature is the SQL that I generate (its a simple example) and can be more elaborate due to the logical operators (AND and OR) given in the XML.
    The problem that we're seeing is performance-based: when one of the logical operator queries is Spatial-based, like below. Running it in JDBC, the query never returns.
    The spatial query just by itself returns ~300 rows (takes approximately 0.2 seconds). The "PERCENTAGE" query by itself returns about ~40000 rows (takes approximately ~.8 seconds).
    If we run the query below with 2 non-spatial subqueries, the result returns and performance is very acceptable (~ 0.9 seconds)-- the result set is about 80000 rows.
    Thanks,
    Jim
    =========================
    SELECT
    COLUMN_WE_WANT , RESULTS
    FROM
    TABLE_A
    WHERE
    COLUMN_WE_WANT IN
    SELECT
    COLUMN_WE_WANT
    FROM
    TABLE_A
    WHERE
    SDO_OVERLAPBDYINTERSECT(TABLE_A.MY_SPATIAL_COLUMN,
    SDO_GEOMETRY(2003,
    4326,
    null,
    SDO_elem_info_array( 1 , 3 , 1 ),
    SDO_ORDINATE_ARRAY( lng_1,lat_1 , lng_2,lat_2 , lng_3,lat_3 , lng_4,lat_4 , lng_1,lat_1 ) )
    ) = 'TRUE'
    OR
    COLUMN_WE_WANT IN
    SELECT
    COLUMN_WE_WANT
    FROM
    TABLE_B
    WHERE
    SOME_PERCENTAGE_RATE_COLUMN < 90
    )

    There is a spatial forum. You will likely have a far better experience there.

  • Hibernet query returns null for XMLTYPE data when I use oracle type4 driver

    Hi,
    I am using Oracle type-4 driver, My hibernet query returns null for data type XMLTYPE. But when I use BEA type -4 driver its working fine. Please help me to retrive XMLTYPE data using oracle-4 driver through hibernet query.
    Thanks in advance.
    regards,
    Amaresh

    Hi,
    I am using Oracle type-4 driver, My hibernet query returns null for data type XMLTYPE. But when I use BEA type -4 driver its working fine. Please help me to retrive XMLTYPE data using oracle-4 driver through hibernet query.
    Thanks in advance.
    regards,
    Amaresh

  • Query form requires Logical operators and/or Quotes

    In ORACLE 9I Jdeveloper beta I used the BC4J JSP wizard to create a - Query Form. The query form looks nice and runs except I have to also include the logical operators (= > <) and Quotes. For example to query on the name Joe I have to enter it as ="JOE". If I use JOE it gives me a JSP error. The error message shows the generated Select statment with the where clause JOE but is missing the "=" and quotes.
    How do I hard code the "=" and quotes around strings so that the user doesn't have to?

    In ORACLE 9I Jdeveloper beta I used the BC4J JSP wizard to create a - Query Form. The query form looks nice and runs except I have to also include the logical operators (= > <) and Quotes. For example to query on the name Joe I have to enter it as ="JOE". If I use JOE it gives me a JSP error. The error message shows the generated Select statment with the where clause JOE but is missing the "=" and quotes.
    How do I hard code the "=" and quotes around strings so that the user doesn't have to?

  • Logical operators in Oracle select query

    Hello all,
    Can i use logical operators in oracle select queries?
    for 1 and 0 =0 ; 1 or 0 =0
    if i have two fileds in a table COL1 have a value of 1010 and COL2 have a value of 0001.
    Is there any way to use select col1 or col2 from table? where or is a logical operator?
    Regards,

    Hi,
    NB wrote:
    Hello all,
    Can i use logical operators in oracle select queries?Sure; Oracle has the logical operators AND, NOT and OR. All the comparison operators, including >, >=, = !=, EXISTS, IN, IS NULL, LIKE and REGEXP_LIKE are really logical operators, since they return logical values. You can use them in SELECT statements, and other places, too.
    for 1 and 0 =0 ; 1 or 0 =0
    if i have two fileds in a table COL1 have a value of 1010 and COL2 have a value of 0001.It's unclear what you want. Maybe you'd be interested in the BITAND function:
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/functions014.htm#sthref1080
    BITAND is the only logical function that I know of. Many other functions, especially numberical fucntions such as MOD, have applications in logic.
    Is there any way to use select col1 or col2 from table? where or is a logical operator?Whenever you have a question, please post a little sample data (CREATE TABLE and INSERT statements), and also post the results you want from that data.
    Explain how you get those results from that data.
    Always say which version of Oracle you're using.

  • Logical operators using "AND" and "OR" operators

    I currently have written code which has two for loops to search a user query. I am able to search user queries entered for a simple and composed query. Eg. Simple query can be "Hello" and composed query can be "Hello World".
    What i would like to do now is be able to use logical operators such as "AND", "OR" when searching e.g. "Hello AND World" or "Hello OR World" Once this is done i would like to score the highest point depending on where the query is found.
    Could someone please help me with either giving me some tips of going about this or some starting code and hints. I have attached some code below which explains what i am currently doing to do the simple query.
    private void SearchButtonActionPerformed(java.awt.event.ActionEvent evt) {                                            
    /* Gets the simple query enterted into the text field. It then looks at the strippedFile in memmory */
    long start = System.currentTimeMillis();
    // long elapsed = System.currentTimeMillis() - start;
    String userQuery = SearchTextField.getText();
    StringTokenizer userQ = new StringTokenizer(userQuery);
    String[] brokenStrings = new String[userQ.countTokens()];
    int counter2 = 0;
    while (userQ.hasMoreTokens()) {
    String moreStrings = userQ.nextToken();
    brokenStrings[counter2] = moreStrings;
    counter2++;
    int Simplematches = 0;
    for (int i = 0; i < strippedFile.length; i++) {
    String LongCurrentLine = strippedFile;
    StringTokenizer st = new StringTokenizer(LongCurrentLine);
    String[] currentline = new String[st.countTokens()];
    int counter = 0;
    while (st.hasMoreTokens()) {
    String moreStrings1 = st.nextToken();
    currentline[counter] = moreStrings1;
    counter++;
    highlighter.highlight(HTMLOutputTextArea, userQuery);
    for (int j = 0; j < brokenStrings.length; j++) {
    for (int k = 0; k < currentline.length; k++) {
    if (brokenStrings[j].equalsIgnoreCase(currentline[k])) {
    long elapsed = System.currentTimeMillis() - start;
    Simplematches++;
    String output = "\"" + currentline[k] + "\" was found on line " + (i + 1) + "." + " At postion " + (k + 1) + " and took " + elapsed + " milliseconds." + " Found " + Simplematches + " matches" + "\n";
    //String output = "\"" + currentline[k] + "\" was found on line " + (i + 1)+ "." + " At postion " + (k + 1) + " Found "+ Simplematches+ " matches"+ "\n";

    jschell wrote:
    london_guy86 wrote:
    jschell wrote:
    Not clear what you search, but....
    First you need to specifically define the syntax. For example what does the following mean?
    a OR b AND c OR d
    Once you do that then you parse the input to create an expression tree. Then you write an interpreter to run the expression tree.Is there any chance you could give me a starter code or soe sources i could look at. I really dont understand how to go about doing what you have mentioned. As in i have declared the syntax at the moment and i am then using the replaceAll() and calling in what i have declared. with empty strings.
    Is this what you mean?Hard to say since I don't understand your statement.
    There are three parts
    1. Parse the expression.
    2. Interpret the expression
    3. Do the "search", this is actually part of 2 however it should be possible to implement some or all of it separate from 1 and 2.
    Do NOT mix the three parts until you are ready to mix them.
    Your posted code is mixing them.
    Presumably what you posted is mostly search. So to start re-write JUST the search code as a class.
    However you can't really do that until you define what the expressions do.After doing everything you mentioned do you think it would be hard to get a score on the best match search found?
    If not could you also give me some tips towards that if you know any.
    Thanks

  • Search format with logical operators in TREX

    We've  activated the index for business object BUS1001006 for material master on SES_ADMIN. The index was created successfully and the two new search help was activated as well. Now testing it in development, I'm trying to figure out how you include logical operators (AND, OR, etc...) inside your search term.
    For example I want to search materials that has ADAPTOR or AMPLIFIER. If I specify exactly "ADAPTOR or AMPLIFIER" (without the quotes) it does not return any search results.
    I'm trying this both on the two new search help and on program COM_SE_SEARCH_IIF_TEST.
    Can you let me know how to do this please ?
    Thanks in advance.

    You have to distinguish between attribute search and full text search:
    In attribute search you can use logical operators by using the generic Select Options just like in any other search help.
    In full text search all entered search words are interpreted with AND conditions.
    If you just press the generic F1 for help on the field "Full Text Search" you will receive the complete standard documentation.
    OR conditions in full text search are not supported because of the restrictions of the generic F4 UI.
    If you want to support OR conditions you should consider installing the SAP product NetWeaver Enterprise Search. The full text search in it's generic search UI contains a query parser that supports the following (and more) features:
    [http://help.sap.com/saphelp_nwes72/helpdata/en/d0/297dfa25a24a57a31e8364ee2ad7eb/frameset.htm]
    Instead of contructing OR conditions it's sometimes much more convenient to browse with NetWeaver Enterprise Search through the distinct value lists of attributes: Read "Narrowing Down Results" in:
    [http://help.sap.com/saphelp_nwes72/helpdata/en/df/f2fb01b6844246b121497b633d83a5/frameset.htm]
    Enjoy! - Klaus

  • Spatial Query, Use Multiple Cores

    Basic question, is SQL 2012 running on Windows 2008 R2 64 bit expected to use multiple cores to execute it's tasks?
    I have a table of points, 480, that has 3 empty columns that are being updated from 3 separate tables of polygons via a spatial join based on an intersection (STIntersects) of the point and polygons. All of the data is in 4326 and all tables have spatial
    indexes.
    The server running this query has 32 logical cores, but only 1 core is used and it is maxed out. It takes 53 seconds to complete the update. I have over a million points that need this done. I want to assume that if SQL can access more cores it will complete
    faster.
    I've looked at the actual execution plan and there is a 99% cost on the spatial query.
    update A
    set CONGRESS_DISTRICT = B.DISTRICT, HOUSE_DISTRICT = C.DISTRICT, SENATE_DISTRICT = D.DISTRICT
    from [LegislativeMapData2014].[dbo].[CNRM_INFORCE_EXTRACT093014_COMBINED_GEOCODED] A
    inner join [LegislativeMapData2014].[dbo].[CONGRESS_2014] B
    on A.FEATURE_SHAPE.STIntersects(B.FEATURE_SHAPE) = 1
    inner join [LegislativeMapData2014].[dbo].[HOUSE_2014] C
    on A.FEATURE_SHAPE.STIntersects(C.FEATURE_SHAPE) = 1
    inner join [LegislativeMapData2014].[dbo].[SENATE_2014] D
    on A.FEATURE_SHAPE.STIntersects(D.FEATURE_SHAPE) = 1
    Is there anything I can do to improve the performance of the query? Do I need to hint the indexes? Or something else?
    Thanks

    Hi,
    updating millions of records could lock your resource and other users may have trouble connecting or reading data.
    In some cases, variable table is your friend, insert the data you needed to a variable table before issuing the update.
    with that, you may need to have (nolock) on each table. eg. 
    [LegislativeMapData2014].[dbo].[CONGRESS_2014] (nolock)
    Regards,
    gioVhan
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Spatial query to find all partially aligned lines

    Hi There.
    I need to find all partially aligned polylines in the layer (interiors have 1-dimentionali intersection). Actually, polylies may a little fluctuate along each other, but that spatial disjointment shouldn't exceed some certain tolerance. It doesn't matter if polylines are touching each other or cover.
    What spatial operators/functions will you suggest to use to perform that stuff?
    For example next lines for me are partially aligned in tolerance 0.01 (query result is TOUCH):
    select sdo_geom.relate(
    mdsys.sdo_geometry(2002,null,null, mdsys.sdo_elem_info_array(1,2,1), mdsys.sdo_ordinate_array(1,1,4,4)),
    'determine',
    mdsys.sdo_geometry(2002,null,null, mdsys.sdo_elem_info_array(1,2,1), mdsys.sdo_ordinate_array(1.1,1,3.015,3)),
    0.01) relationship
    from dual;
    Note: I can't use buffers because it isn't stable for me :( see: SDO_GEOM.SDO_BUFFER failed with ORA-13050
    Thank you in advance, Denis.

    Thank you for quick response!
    The lines are valid at that tolerance.
    I think that TOUCH+COVERS+COVEREDBY will not be sufficient for me. Because I'm interested in next cases: OVERLAPBDYINTERSECT, INSIDE, CONTAINS, COVERS (any operator which includes overlapping for lines). I can use union of all those masks, but TOUCH will return me many redundant candidates (Often lines are touch but not overlapping, like: (1,1,2,2) VS (2,2,3,3)). The TOUCH works for me if one poliline touches the other and goes along it some time (like I showed above). Hope I was clear :).

  • Spatial Query - sdo_aggr_union

    Hi
    I am a newbie to oracle spatial (Database 11g) and am having an issue with sdo_aggr_union
    i have the following cursor
    CURSOR get_buffer_union IS
    SELECT sdo_aggr_union(sdoaggrtype(coverage,0.5)) coverage
    FROM
    (SELECT sdo_aggr_union(sdoaggrtype(coverage,0.5)) coverage
    FROM
    (SELECT sdo_aggr_union(sdoaggrtype(coverage,0.5)) coverage
    FROM
    (SELECT sdo_aggr_union(sdoaggrtype(coverage,0.5)) coverage
    FROM
    (SELECT sdo_aggr_union(mdsys.sdoaggrtype(geom,0.5)) coverage
    FROM rep_geo_acc_buffer
    where extraction_date = trunc(sysdate)
    GROUP BY mod(rownum,128))
    GROUP BY mod (rownum, 32))
    GROUP BY mod (rownum, 8))
    GROUP BY mod (rownum, 2)
    The result i am getting back is null. If I run the inner statement i get back 128 rows. Is it possible that this result is being held in cache and this is not the true result or is there someting wrong with the query.

    Wellcome to OTN Forums!
    Why you are using GROUP BY inner GROUP BY?
    What is your logic?
    CURSOR get_buffer_union IS
    SELECT sdo_aggr_union(sdoaggrtype(coverage,0.5)) coverage
    FROM
    (SELECT sdo_aggr_union(sdoaggrtype(coverage,0.5)) coverage
    FROM
    (SELECT sdo_aggr_union(sdoaggrtype(coverage,0.5)) coverage
    FROM
    (SELECT sdo_aggr_union(sdoaggrtype(coverage,0.5)) coverage
    FROM
    (SELECT sdo_aggr_union(mdsys.sdoaggrtype(geom,0.5)) coverage
    FROM rep_geo_acc_buffer
    where extraction_date = trunc(sysdate)
    GROUP BY mod(rownum,128))
    GROUP BY mod (rownum, 32))
    GROUP BY mod (rownum, 8))
    GROUP BY mod (rownum, 2)
    );

  • Advanced Search using conditional & logical operators+ sharepoint 2010

    Hi Team,
    We have an requirement something like this. we have to search values from Custom SharePoint List using Conditional & Logical Operators in SharePoint 2010. how can i achieve this ? if some one has worked on something like this, can you please share the
    details to my email id ([email protected]
    Thanks in Advance.
    Cheers, San

    Hi Santhosh,
    If you have only one list, then you can use CAML query to perform search in that list. You can write code to generate dynamic CAML based on selection in the filter.
    If have to perform the search function on multiple list then you can use Search object model and create dynamic query and execute it using Search OM.
    http://msdn.microsoft.com/en-us/library/office/dn423226(v=office.15).aspx
    Best Regards,
    Brij K

  • PHP logical operators

    I have the following line of code that works fine in a page:
    if(($_POST['Alsubmit']) && (isset($unique) == FALSE))
    the code checks that the Alsubmit form has been submitted,
    AND that the text input is unique, $unique is a statement that says
    "you already have an album of that name" and is set if there is a
    match from a query.
    What i want is to add a || to the end like this
    if(($_POST['Alsubmit']) && (isset($unique) == FALSE))
    || (isset($_GET['album']) == TRUE) {
    so (if post Alsubmit and $unique not set) OR (get album is
    set) {
    show form here
    Can i have two sets of logical operators in one statemnet?

    .oO(MikeL7)
    >I have the following line of code that works fine in a
    page:
    > if(($_POST['Alsubmit']) && (isset($unique) ==
    FALSE)) {
    Better:
    if (isset($_POST['Alsubmit']) && !isset($unique)) {
    > What i want is to add a || to the end like this
    > if(($_POST['Alsubmit']) && (isset($unique) ==
    FALSE)) ||
    >(isset($_GET['album']) == TRUE) {
    > so (if post Alsubmit and $unique not set) OR (get album
    is set) {
    > show form here
    > }
    >
    > Can i have two sets of logical operators in one
    statemnet?
    Sure. You just have some misplaced or missing parentheses.
    Try:
    if ((isset($_POST['Alsubmit']) && !isset($unique))
    || isset($_GET['album'])) {
    Micha

  • SSRS - SQL Server Spatial Query

    Hi, I was hoping someone could help me.
    I'm creating an SSRS report with Map and importing points via SQL Server Spatial query. I have a db table with 8,000 points bu the import only ever brings in the first 2,000 queried (no matter what the filter is). Is there a limitation in SSRS that can be
    changed via a configuration setting?
    Many thanks in advance for any help on this,
    Steve.

    Really appreciate you coming back so quick Olaf.
    No its a straightforward query (select AccountNum, Name, Address, Longitude, Lattitude, UrbanArea, County, MI_STYLE, MI_PRINX, SP_GEOMETRY from <table>)
    Just to give the whole picture. I had 8,000 points in MapInfo version 10. I imported them to SQL Server 2012 via MapInfo Easy Loader.
    The SQL Server spatial points import to SSRS and the Bing overlay map works great (so they import to correct space) but its only a subset of the points that import. I can pick any subset using the WHERE clause but I cannot get all 8,000 points.  
    I was hoping there was a configuration setting somewhere in SSRS that was causing the problem.

  • Spatial query in a distributed environment

    We want to compare two spatial tables.
    We have (at present identical) tables on two computers GEOSRV0 and NB25.
    On both we have Oracle 10.1.0.2. GEOSRV0 has the WINDOWS 2000 operating system installed, on NB25 there is WINDOWS XP Professional.
    The table is EZG:
    GEOMETRY MDSYS.SDO_GEOMETRY
    GEOMETRY_SK VARCHAR2(15)
    EZG_NR NOT NULL NUMBER
    FLAECHE FLOAT(126)
    The primary key is EZG_NR.
    There is a private database link for the user WLKREP on NB25 to user WLKREP on GEOSRV0.
    The USER_SDO_GEOM_METADATA are the same on both machines (same SRID, same DIMINFO).
    The following query – we check, if for each record on NB25 is a record on GEOSRV0 - works normally:
    SQL> select ezg_nr from
    2 ezg a where not exists
    3 (select 1 from wlkrep.ezg@wlk where ezg_nr=a.ezg_nr);
    no rows selected
    This is correct.
    We can read the geometry on the remote database:
    SQL> select * from wlkrep.ezg@wlk where rownum=1;
    GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    GEOMETRY_SK EZG_NR FLAECHE
    SDO_GEOMETRY(3003, 1040001, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARRAY(182285.489, 405672.889, 0, 182248.701, 405644.889, 0, 182241.984, 405639.771, 0, 182171.753, 405538.805, 0, 182130.953, 405498.016, 0, 181971.1, 405274.91
    6, 0, 182223.796, 405176.609, 0, 182292.701, 405204.37, 0, 182439.028, 405451.66
    , 0, 182573.506, 405628.153, 0, 182643.64, 405726.59, 0, 182718.945, 405764.608,
    0, 182780.371, 405805.57, 0, 182862.191, 405843.931, 0, 182966.69, 405933.13, 0
    , 183131.065, 406064.852, 0, 183205.098, 406160.637, 0, 183231.535, 406220.959,
    0, 183266.473, 406265.415, 0, 183308.669, 406303.524, 0, 183295.305, 406364.696,
    0, 183204.283, 406331.35, 0, 183161.835, 406299.691, 0, 183134.554, 406243.403,
    GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    GEOMETRY_SK EZG_NR FLAECHE
    0, 183080.454, 406171.548, 0, 183027.376, 406123.698, 0, 182914.558, 406039.291
    , 0, 182770.335, 405973.138, 0, 182593.691, 405886.413, 0, 182443.506, 405795.85
    2, 0, 182343.293, 405713.991, 0, 182285.489, 405672.889, 0))
    13 304906.065
    Now we want to compare the geometry and get
    SQL> select a.ezg_nr from
    2 wlkrep.ezg@wlk b, ezg a where a.ezg_nr=b.ezg_nr and
    3 sdo_equal(a.geometry,b.geometry) != 'TRUE';
    select a.ezg_nr from
    ERROR at line 1:
    ORA-03113: end-of-file on communication channel
    Only comparing two elements gives the same result
    SQL> select a.ezg_nr from
    2 wlkrep.ezg@wlk b, ezg a where a.ezg_nr=640 and
    3 b.ezg_nr = 640 and
    4 sdo_equal(a.geometry,b.geometry) = 'TRUE';
    select a.ezg_nr from
    ERROR at line 1:
    ORA-03113: end-of-file on communication channel
    Even if we query a non existing element
    select count(*) from ezg where ezg_nr=99999;
    COUNT(*)
    0
    SQL> select a.ezg_nr from
    2 wlkrep.ezg@wlk b, ezg a where a.ezg_nr=99999 and
    3 b.ezg_nr = 99999 and
    4 sdo_equal(a.geometry,b.geometry) = 'TRUE';
    select a.ezg_nr from
    ERROR at line 1:
    ORA-03113: end-of-file on communication channel
    Is this a bug or is a distributed spatial query not supported?
    The following statement works:
    SQL> select a.ezg_nr from
    2 wlkrep.ezg@wlk a where not exists
    3 (select 1 from ezg b where
    4 b.ezg_nr=a.ezg_nr and
    5 sdo_equal(b.geometry,a.geometry)='TRUE');
    no rows selected
    Regards
    Karl

    Actually, I have filed a TAR to Oracle on this. I also spoke to Steve Muench about it at OracleWorld, briefly. As of today, I'm trying to add to DataScroller.java to make it implement java.io.Serializable (with no luck...maybe someone can comment on what I'm doing wrong).
    Here's what I have done so far.
    Changed DataScroller.java (located in bc4jhtmlsrc.zip) to the following:
    public class DataScroller implements java.io.Serializable
    I added the following members per the docs on java.io.Serializable
    private void writeObject(java.io.ObjectOutputStream out)
    throws IOException
    // really don't need to save state. Next call will recompute what's necessary
    private void readObject(java.io.ObjectInputStream in)
    throws IOException, ClassNotFoundException
    // really don't need to load state. Next call will recompute what's necessary
    I then used jar xvf to "unjar" datatags.jar, replaced DataScroller.class with my version and used
    jar cv0Mf datatags.jar META-INF/* oracle/*
    to recreate the datatags.jar. My file is not 100% the exact same as their file, but it looks to be right to me. I ended up doing it this way because the oracle\ord\* classes are not in the bc4jhtmlsrc.zip, only in the jar file and felt this was the "safest" way to include the correct contents of the file.
    HOWEVER -- I'm sorry to say that I've then tried to run my app and get the same issue.
    Thanks,
    Jeff

  • Not using Index when SDO_RELATE in Spatial Query is used in LEFT OUTER JOIN

    I want to know for every City (Point geometry) in which Municipality (Polygon geometry) it is.
    Some cities will not be covered by any municipality (as there is no data for it), so its municipality name should be blank in the result
    We have 4942 cities (point geometries)
    and 500 municipalities (polygon geometry)
    SELECT T1.NAME as City, T2.NAME as Municipality
    FROM CITY T1
    LEFT OUTER JOIN MUNICIPALITY T2 ON SDO_RELATE(T1.GEOM, T2.GEOM, 'MASK=ANYINTERACT') = 'TRUE'The explain plan for this query is:
    SELECT STATEMENT
      FILTER
        Filter Predicates
          MDSYS.SDO_RTREE_RELATE(T1.GEOM, T2.GEOM, 'mask=ANYINTERACT querytype=window ') = 'TRUE'
        MERGE JOIN
          TABLE ACCESS              CITY               FULL                            11
          BUFFER                                       SORT                        100605
              TABLE ACCESS          MUNICIPALITY       FULL                            20So the cost is in the BUFFER (whatever that is), it takes +2000 seconds to run this, it is not using the spatial index.
    And we are not getting all rows, but only the ones interacting with a municipality, e.g. 2436 rows.
    But I want all rows, including the ones not interacting with any Municipality.
    When we want only those cities that actually are in a municipality, I use a different query and it will use the index.
    SELECT T1.NAME as City, T2.NAME as Municipality
    FROM CITY T1, MUNICIPALITY T2
    WHERE SDO_RELATE(T1.GEOM, T2.GEOM, 'MASK=ANYINTERACT') = 'TRUE'I get (only) 2436 rows (as expected) in 5 seconds (it is fast) and the explain plan shows it is using the spatial index.
    But in this case, I am not getting any cities not inside any municipality (of course)
    SELECT STATEMENT
       NESTED LOOPS
          TABLE ACCESS                   MUNICIPALITY       FULL                22
          TABLE ACCESS                   CITY               BY INDEX ROWID      22
             DOMAIN INDEX                CITY_SDX                                0
                Access Predicates
                   MDSYS.SDO_RTREE_RELATE(T1.GEOM, T2.GEOM, 'mask=ANYINTERACT querytype=window ') = 'TRUE'I always thought a LEFT OUTER JOIN would return all rows from the Table, whatever happens in the next,
    but it seems the query has been rewritten so that it is now using a Filter Predicate in the end, which filters those geometries having no interaction.
    As an example I also do thing alphanumerically, I do get 4942 rows, including the ones which have no Municipality name.
    In this case the names must match, so its only for testing if the LEFT OUTER JOIN returns stuff correctly, which it does in this case.
    SELECT T1.NAME as City, T2.NAME as Municipality
    FROM CITY T1
    LEFT OUTER JOIN MUNICIPALITY T2 ON T1.NAME = T2.NAMEIs this an Oracle Spatial bug, e.g. not return 4942 rows, but only 2436 rows on the first query?
    Note all tests performed on Oracle 11g R2 (11.2.0.1.0)

    Patrick,
    Even so, your geoms in the relate were the wrong way around.
    Also, I don't recall you saying (or showing) that you wanted the municipality geometry returned. Still,
    no matter, easy to do.
    Here are some additional suggestions. I don't have your data so I have had to use some of my own.
    set serveroutput on timing on autotrace on
    SELECT T1.SPECIES as City,
           (SELECT T2.ADMIN_NAME FROM AUSTRALIAN_STATES T2 WHERE SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE') as Municipality,
           (SELECT T2.GEOM       FROM AUSTRALIAN_STATES T2 WHERE SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE') as geom
      FROM GUTDATA T1;
    762 rows selected
    Elapsed: 00:00:21.656
    Plan hash value: 2160035213
    | Id  | Operation                   | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |                            |   762 | 49530 |     5   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| AUSTRALIAN_STATES          |     1 |   115 |     0   (0)| 00:00:01 |
    |*  2 |   DOMAIN INDEX              | AUSTRALIAN_STATES_GEOM_SPX |       |       |     0   (0)| 00:00:01 |
    |   3 |  TABLE ACCESS BY INDEX ROWID| AUSTRALIAN_STATES          |     1 |   115 |     0   (0)| 00:00:01 |
    |*  4 |   DOMAIN INDEX              | AUSTRALIAN_STATES_GEOM_SPX |       |       |     0   (0)| 00:00:01 |
    |   5 |  TABLE ACCESS FULL          | GUTDATA                    |   762 | 49530 |     5   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"(:B1,10000,0.5,'UNIT=M'))='TRUE')
       4 - access("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"(:B1,10000,0.5,'UNIT=M'))='TRUE')
       Statistics
                   7  user calls
               24576  physical read total bytes
                   0  physical write total bytes
                   0  spare statistic 3
                   0  commit cleanout failures: cannot pin
                   0  TBS Extension: bytes extended
                   0  total number of times SMON posted
                   0  SMON posted for undo segment recovery
                   0  SMON posted for dropping temp segment
                   0  segment prealloc tasksThe above can look messy as you add more (SELECT ...) attributes, but is is fast (though can't use in Materialized Views).
    /* The set of all cities not in municipalities */
    SELECT T1.SPECIES                 as City,
           cast(null as varchar2(42)) as municipality,
           cast(null as sdo_geometry) as geom
      FROM GUTDATA T1
    WHERE NOT EXISTS (SELECT 1
                         FROM AUSTRALIAN_STATES T2
                        WHERE SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE')
    UNION ALL
    /* The set of all cities in municipalities */
    SELECT T1.SPECIES    as City,
           T2.ADMIN_NAME as Municipality,
           T2.GEOM       as geom
      FROM GUTDATA T1
           INNER JOIN
           AUSTRALIAN_STATES T2 ON (SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE');
    762 rows selected
    Elapsed: 00:00:59.953
    Plan hash value: 2854682795
    | Id  | Operation           | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |                            |    99 | 13450 |    38  (87)| 00:00:01 |
    |   1 |  UNION-ALL          |                            |       |       |            |          |
    |*  2 |   FILTER            |                            |       |       |            |          |
    |   3 |    TABLE ACCESS FULL| GUTDATA                    |   762 | 49530 |     5   (0)| 00:00:01 |
    |*  4 |    DOMAIN INDEX     | AUSTRALIAN_STATES_GEOM_SPX |       |       |     0   (0)| 00:00:01 |
    |   5 |   NESTED LOOPS      |                            |    61 | 10980 |    33   (0)| 00:00:01 |
    |   6 |    TABLE ACCESS FULL| AUSTRALIAN_STATES          |     8 |   920 |     3   (0)| 00:00:01 |
    |*  7 |    TABLE ACCESS FULL| GUTDATA                    |     8 |   520 |     4   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter( NOT EXISTS (SELECT 0 FROM "AUSTRALIAN_STATES" "T2" WHERE "MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"(:B1,10000,0.5,'UNIT=M'))='TRUE'))
       4 - access("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"(:B1,10000,0.5,'UNIT=M'))='TRUE')
       7 - filter("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"("T1"."GEOM",10000,0.5,'UNIT=M'))='TRUE')
       Statistics
                   7  user calls
              131072  physical read total bytes
                   0  physical write total bytes
                   0  spare statistic 3
                   0  commit cleanout failures: cannot pin
                   0  TBS Extension: bytes extended
                   0  total number of times SMON posted
                   0  SMON posted for undo segment recovery
                   0  SMON posted for dropping temp segment
                   0  segment prealloc tasksMuch slower but Materialized View friendly.
    This one is a bit more "natural" but still slower than the first.
    set serveroutput on timing on autotrace on
    /* The set of all cities in municipalities */
    WITH municipal_cities As (
      SELECT T1.ID         as City,
             T2.ADMIN_NAME as Municipality,
             T2.GEOM       as geom
        FROM GUTDATA T1
             INNER JOIN
             AUSTRALIAN_STATES T2 ON (SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE')
    SELECT T1.ID           as City,
           T2.Municipality as Municipality,
           T2.GEOM         as geom
      FROM GUTDATA          T1
           LEFT OUTER JOIN
           municipal_cities T2
           ON (T2.CITY = T1.ID);
    762 rows selected
    Elapsed: 00:00:50.228
    Plan hash value: 745978991
    | Id  | Operation             | Name              | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT      |                   |   762 | 44196 |    36   (3)| 00:00:01 |
    |*  1 |  HASH JOIN RIGHT OUTER|                   |   762 | 44196 |    36   (3)| 00:00:01 |
    |   2 |   VIEW                |                   |    61 |  3294 |    33   (0)| 00:00:01 |
    |   3 |    NESTED LOOPS       |                   |    61 | 10980 |    33   (0)| 00:00:01 |
    |   4 |     TABLE ACCESS FULL | AUSTRALIAN_STATES |     8 |   920 |     3   (0)| 00:00:01 |
    |*  5 |     TABLE ACCESS FULL | GUTDATA           |     8 |   520 |     4   (0)| 00:00:01 |
    |   6 |   INDEX FAST FULL SCAN| GUTDATA_ID_PK     |   762 |  3048 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - access("T2"."CITY"(+)="T1"."ID")
       5 - filter("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"("T1"."GEOM",10000,0.5,'UNIT=M'))='TRUE')
       Statistics
                   7  user calls
               49152  physical read total bytes
                   0  physical write total bytes
                   0  spare statistic 3
                   0  commit cleanout failures: cannot pin
                   0  TBS Extension: bytes extended
                   0  total number of times SMON posted
                   0  SMON posted for undo segment recovery
                   0  SMON posted for dropping temp segment
                   0  segment prealloc tasksFinally, the Pièce de résistance: trick the LEFT OUTER JOIN operator...
    set serveroutput on timing on autotrace on
    SELECT T1.SPECIES    as City,
           T2.ADMIN_NAME as Municipality,
           T2.GEOM       as geom
      FROM GUTDATA           T1
           LEFT OUTER JOIN
           AUSTRALIAN_STATES T2
           ON (t2.admin_name = to_char(t1.ID) OR
               SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE');
    762 rows selected
    Elapsed: 00:00:50.273
    Plan hash value: 158854308
    | Id  | Operation           | Name              | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |                   |   762 | 92964 |  2294   (1)| 00:00:28 |
    |   1 |  NESTED LOOPS OUTER |                   |   762 | 92964 |  2294   (1)| 00:00:28 |
    |   2 |   TABLE ACCESS FULL | GUTDATA           |   762 | 49530 |     5   (0)| 00:00:01 |
    |   3 |   VIEW              |                   |     1 |    57 |     3   (0)| 00:00:01 |
    |*  4 |    TABLE ACCESS FULL| AUSTRALIAN_STATES |     1 |   115 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - filter("T2"."ADMIN_NAME"=TO_CHAR("T1"."ID") OR
                  "MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"("T1"."GEOM",10000,0.5,'UNIT=M'))='TRUE')
       Statistics
                   7  user calls
                   0  physical read total bytes
                   0  physical write total bytes
                   0  spare statistic 3
                   0  commit cleanout failures: cannot pin
                   0  TBS Extension: bytes extended
                   0  total number of times SMON posted
                   0  SMON posted for undo segment recovery
                   0  SMON posted for dropping temp segment
                   0  segment prealloc tasksTry these combinations to see what works for you.
    Interestingly, for me, the following returns absolutely nothing.
    SELECT T1.SPECIES    as City,
           T2.ADMIN_NAME as Municipality
      FROM GUTDATA           T1
           LEFT OUTER JOIN
           AUSTRALIAN_STATES T2
           ON (SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE')
    MINUS
    SELECT T1.SPECIES    as City,
           T2.ADMIN_NAME as Municipality
      FROM GUTDATA           T1
           LEFT OUTER JOIN
           AUSTRALIAN_STATES T2
           ON (t2.admin_name =  to_char(t1.ID) OR
               SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE');(I leave it to you to see if you can see why as the LEFT OUTER JOIN seems to be working correctly for me but I am not going to dedicate time to detailed checking of results.)
    Note all tests performed on Oracle 11g R2 (11.2.0.1.0)
    If you get the answer you want: mark the post as answered to assign points.
    regards
    Simon

Maybe you are looking for

  • How do I set a link in an HTML file that points to a spot in a PDF?

    I want to go from an HTML file to a spot in a PDF. By spot in a PDF, I mean a location marked by a bookmark. What is the equivalent in a PDF file to the anchor tag in HTML with a name attribute? What HTML code do I use? If I use Word to make the PDF,

  • Index seen in RoboHelp does not match CHM

    I have a project which has conditional text and topics to enable me to create different CHM Help files for four variations of an application. I haven't noticed any problems with the indexes in previous versions of the Help files that I've generated b

  • Help Please....Missing Fonts

    After a recent archive and reinstall, I opened iWeb and received the message, "The following errors occurred while trying to open this document." Apparently, I am missing the following fonts: CourierNewPSMT Handwriting-Dakota AcademyEngravedLetPlain

  • How to start from scratch?

    My G40 2388 is running slow although I have increased the memory. I spoke to a computer sales person who did not try to sell me a new laptop but said that it could help to make backup of all documents etc and then reinstall everything and start from

  • Reversal of Goods received at a cost centre.

    A PO has been created with Account Assignment: X and Item Category: S This is basically a Third Party Scenario. The goods have been received at a cost center. How to reverse this Goods Receipt. PN: This is not cancellation of GR, it is reversal.