Spatial query (point in poly) problem

Hi
One of my users is trying to run the following query in SQL*Plus:
CREATE TABLE erdpwip_join AS
SELECT A.CSNGC, B.PARCELID
FROM RLR.RLR87_SK B, ERDPWIPDATA A
WHERE sdo_relate (a.geom, b.geom, 'mask=ANYINTERACT querytype=Window') = 'TRUE'
He says it works on a small subset of the full dataset, but when he tries to run it on a larger selection of data it stops working. The full dataset has 1.6 million shapes and is held in an Oracle 9.2.0.5.0 database. It isn't clean data, unfortunately: I performed an sdo_geom.validate_layer_with_context on it and removed around 240 shapes with errors (mostly self-intersects), but when trying to access the dataset through ESRI's ArcSDE (version 8.3) a load_buffer error -2035 occurs, which I am informed is because there are other low-level self-intersects which Oracle's validation routine didn't pick up.
There are two questions really: first, is the quality of the data (with these geometric errors) the reason for the user's point-in-polygon query not working on larger recordsets (e.g. about 400000 records), or is because of the volume of data?
Secondly, is there any way that Oracle's validation routines will pick up these low-level self-intersects which were missed in the first pass? ESRI's support forum recommends running a query on the dataset which steps through so many records at a time until it finds an error - the full thread is at http://forums.esri.com/Thread.asp?c=2&f=1720&t=152985&mc=1.
Any help would be appreciated.
Thanks
Sharon Evans

Hi Sharon,
What does "it stops working" mean? Error? Long running query?
Assuming your data is now clean in spatial, I would try creating the table, then loading it with the query using the ordered hint. The number of geometries, while affecting run time, is certainly not more than spatial can handle.
CREATE TABLE erdpwip_join AS
SELECT A.CSNGC, B.PARCELID
FROM RLR.RLR87_SK B, ERDPWIPDATA A
WHERE rownum < 1;
insert into erdpwip_join
SELECT /*+ ordered */ A.CSNGC, B.PARCELID
FROM RLR.RLR87_SK B, ERDPWIPDATA A
WHERE sdo_relate (a.geom, b.geom, 'mask=ANYINTERACT querytype=Window') = 'TRUE';
Regarding drawing in ESRI and tolerance/validation:
In Oracle Spatial the tolerance is specified as the distance two points have to be apart to be considered different.
I think for ESRI, points have to be greater than tolerance apart (not exactly tolerance apart, which is fine in spatial).
So what you might want to try is kicking up the tolerance by some very small increment for the validation, remove or fix those invalid geometries, reset the tolerance back to the smaller value, and then try using ArcSDE again.
I haven't tried this at all, so if you can let us know if this works we'll know this is probably a good general recommendation.

Similar Messages

  • Point in Poly query?

    How do I perform a simple point in poly query with spatial?
    If I have a set of coordinates (-86.524442 39.7748187) for which I want to know which polygon they fall inside of?
    Thanks in advance-M.

    A query like this should get what you're after :
    select county
    from counties c
    where sdo_relate(c.geom, mdsys.sdo_geometry(2001,
    null,
    mdsys.sdo_point_type(-86.524442,39.7748187,null),
    null, null),
    'mask=contains querytype=window') = 'TRUE'
    This will return "Hendricks" county which I believe is correct.
    The relevant parms for the mdsys.sdo_geometry object are the "2001" which specifies a point object and then the creation of the actual sdo_point_type itself. The third parm to this object is null as that is the Z access.
    The Oracle Spatial Users Guide is very useful and has lots of information and examples of this kind of thing.
    Steve

  • Index problem in a spatial query

    I try to run following query in SQL Plus:
    SELECT A.objectid FROM TABBDG A, TABREG B
    WHERE A.objectid = 68 AND B.regionname = 'Hong2'
    AND SDO_RELATE(A.geoloc, B.geoloc, 'mask=INSIDE querytype = WINDOW') = 'TRUE';
    To find out weather or not objectid = 68 is inside of region (='Hong2"). I got following error messages:
    ERROR at line 1:
    ORA-13226: interface not supported without a spatial index
    ORA-06512: at "MDSYS.MD", line 1723
    ORA-06512: at "MDSYS.MDERR", line 8
    ORA-06512: at "MDSYS.SDO_3GL", line 57
    ORA-06512: at line 1
    But when I try to add an index to table TABREG, I got following error:
    ERROR at line 1:
    ORA-29879: cannot create multiple domain indexes on a column list using same indextype
    Seem to me that the index was already there. Can any one help me? Thanks.

    I found out the reason of problem. I used an old version of EasyLoader (4.5?). When I get the latest EasyLoader V6.5, there is no problem any more to run spatial query. You can get lates EasyLoader V6.5 from MapInfo or from me at: [email protected]
    Thanks for all help.

  • 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.

  • Oracle 9i 10g slow spatial query

    I have been using the following spatial query in oracle 9i to assign jurisdictions to spatial points.
    SELECT /*+ordered*/ L.TCH_X_COORD, L.TCH_Y_COORD, T.NAME
    FROM tis.tis_coordinates_hold_on L,
    geospatial.mdt_admin_districts T
    WHERE SDO_RELATE(T.GEOMETRY,
    MDSYS.SDO_GEOMETRY(2001,41079,MDSYS.SDO_POINT_TYPE(tch_x_coord,tch_y_coord,NULL),
    NULL,NULL),'mask=ANYINTERACT querytype=WINDOW') = 'TRUE'
    AND tch_assigned_base_rte='M00001N'
    By using the ordered hint I was able to double the retrieval rate.  My problem is this: We are now migrating to oracle 10g, and the use of the ordered returns no rows (different incorrect results). If I remove the + ordered the results are correct, but I no longer get the increased speed of retrieval. Has anyone run into this problem, and can you suggest a way that I could speed up this query. As it stands now it takes more than 1/2 sec for each record retrieved, and I have millions of records !! Thanks.

    We're using 10.2.4.0 I believe I have found the reason the queries were different. When I dropped the spatial index and re-created it, the query returned the same rows as 9i. However, I still have an issue with the speed. 10g appears to be about 1/3 as fast as 9i was. It doesn't seem to make any difference whether I put in the +ordered or not.  Our dba says just based on cpu and processing speed the server that has 10g should be significantly faster.  Any comments?  Thanks.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Combined flat (regular) and Spatial query

    DB: Oracle 8.1.7.2.1 (8i Release 3, patch 81721)
    I performed a spatial query on the results of a regular query, in the form of:
    Select count(*) from
    (select * from myTable where key=...)
    WHERE (MDSYS.SDO_RELATE("GEOLOC",
    MDSYS.SDO_GEOMETRY(2003,NULL,null,
    MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,3),
    MDSYS.SDO_ORDINATE_ARRAY(-118.83939716391866,
    29.951783100000025, -100.20650379608135,
    40.52319191999998)),
    'mask=ANYINTERACT layer_gtype=POINT
    querytype = WINDOW')='TRUE');
    The first flat query results in a small number of records and takes minimum time if run separately.
    Select count(*) from
    (select * from myTable where key=...)
    However, when appended the spatial join condition, it takes a long time, same as querying from the whole dataset without the first flat query. I tried to optimize the spatial index and it did not help much.
    Why isn't the spatial query taking advantage of the flat query? Can I somehow force it to do so to improve the performance? (This is a dynamic query in an application.)
    Thanks.

    Hi
    I have a similar problem and i'd like to know if anyone have got a solution.
    We are developing a vehicle localization system.
    The amount of data it's about 6 million positions per year.
    The queries to the data could be the actual location of the vehicle (100 vehicles) or historical locations.
    For historical location we have partitioned the table an index by date (each week), and for actual location we have created a bitmap index based on field L_ULTIMA.
    Allwais the queries are filtered by alfanumeric conditions more restrictive then spatial (range of dates or last_location).
    When runnin alfanumeric queries over a subset of une million rows, it takes only few seconds (even less) but when including spatial conditions (SDO_RELATE to a rectangle) it takes more than one minute.
    We have tried different hints to force the use of bitmap index but in all cases the execution plan uses de spatial index.
    It's there any way to combine spatial and flat indexes?
    SELECT
    COUNT(*)
    FROM SLFP_LOCALIZACIONES A
    WHERE sdo_relate(A.geom, mdsys.sdo_geometry(2003,NULL,NULL,
    mdsys.sdo_elem_info_array(1,1003,3),
    mdsys.sdo_ordinate_array(159657,3978069, 546051,4116358)),
    'mask=anyinteract querytype=window') = 'TRUE';
    COUNT(*)
    899073
    Transcurrido: 00:02:126.34
    SELECT /*+ INDEX_COMBINE(A SLFP_LOCALI_ULTIMA_I) */
    COUNT(*)
    FROM SLFP_LOCALIZACIONES A
    WHERE sdo_relate(A.geom, mdsys.sdo_geometry(2003,NULL,NULL,
    mdsys.sdo_elem_info_array(1,1003,3),
    mdsys.sdo_ordinate_array(159657,3978069, 546051,4116358)),
    'mask=anyinteract querytype=window') = 'TRUE' AND
    A.L_ULTIMA = 1;
    COUNT(*)
    102
    Transcurrido: 00:02:121.00
    SELECT COUNT(*) FROM SLFP_LOCALIZACIONES WHERE L_ULTIMA = 1
    COUNT(*)
    104
    Transcurrido: 00:00:00.72
    SQL> SELECT /*+ INDEX_COMBINE(A SLFP_LOCALI_ULTIMA_I) */
    2 COUNT(*)
    3 FROM SLFP_LOCALIZACIONES A
    4 WHERE N_X >= 159657 AND
    5 N_X <= 546051 AND
    6 N_Y >= 3978069 AND
    7 N_Y <= 4116358 AND
    8 A.L_ULTIMA = 1;
    COUNT(*)
    102
    Transcurrido: 00:00:00.59

  • Oracle spatial query SDO_LRS with php

    Hello, I have this problem,
    I use php for read data from oracle table.
    I know I can't show on web page the result of SDO_ORDINATE_ARRAY
    Christopher Jones has written that I must use SDO_UTIL.GETVERTICES like as
    select
    t.X,
    t.Y
    from table_a, TABLE(SDO_UTIL.GETVERTICES(table_a.GEOMETRY_1)) t
    where
    id_num = 970;
    But now I must read a projection point ordinate of a point with respect to a geometric segment
    and the same problem come back.
    esemple of spatial query that I use:
    SELECT
    SDO_LRS.PROJECT_PT(geometry,
    SDO_GEOMETRY(3301, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 1), SDO_ORDINATE_ARRAY(580094.69, 4998493.68, NULL)) )
    FROM
    TABLE_B
    WHERE
    ID_CODE = 970;
    If I use sql plus I have this result
    SDO_LRS.PROJECT_PT(GEOMETRY,SD(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM
    SDO_GEOMETRY(3301, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 1), SDO_ORDINATE_ARRAY(
    580093,325, 4998497,57, 45,2254405))
    Which is exacly the query for extract these coordinates?
    Someone can help me?
    My English is very bad please reply easy.
    Thanks for all!
    Angelo

    Hello thanks for all to everyboby.
    I put the same question on Forum /Category/Database/Spatial and I have received this reply
    from Brian Camire, this query worked well.
    SELECT
    T.X,
    T.Y
    FROM
    TABLE
    SELECT
    SDO_UTIL.GETVERTICES
    SDO_LRS.PROJECT_PT
    GEOMETRY,
    SDO_GEOMETRY
    3301,
    NULL,
    NULL,
    SDO_ELEM_INFO_ARRAY(1, 1, 1),
    SDO_ORDINATE_ARRAY(580093.859, 4998493.5, NULL)
    FROM
    TABLE_B
    WHERE
    ID_CODE = 970
    ) T;
    Best regards
    Angelo.

  • Bugy nearest neighbour spatial query?

    Hi,
    I have the following problem. The last query below returns the bad number of rows and I suspect some RDBMS bug behinde this, but am not really shure. Could some one please have a look?
    -- Preparation steps:
    -- Create 'Varos' Table
    CREATE TABLE VAROS (
    GMIPRIMARYKEY NUMBER (10) NOT NULL,
    TNEV VARCHAR2 (50),
    NEV VARCHAR2 (50),
    GEOMETRY MDSYS.SDO_GEOMETRY,
    PRIMARY KEY ( GMIPRIMARYKEY ));
    -- Insert 5 records
    --           2 have no name (nev attribute contains 'nincs neve')
    --          3 have meaningful name
    insert into varos values (615484,'Kisszentmarton','58131',MDSYS.SDO_GEOMETRY(2002,NULL,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),MDSYS.SDO_ORDINATE_ARRAY(18.04725,45.788384,18.04698,45.786578)));
    insert into varos values (617351,'Czn','nincs neve',MDSYS.SDO_GEOMETRY(2002,NULL,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),MDSYS.SDO_ORDINATE_ARRAY(18.060483,45.785141,18.060615,45.784949,18.06079,45.783938,18.061508,45.782226,18.061641,45.781539,18.061686,45.780696,18.061677,45.780531)));
    insert into varos values (617352,'Czn','nincs neve',MDSYS.SDO_GEOMETRY(2002,NULL,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),MDSYS.SDO_ORDINATE_ARRAY(18.061677,45.780531,18.061638,45.779749,18.061463,45.778458,18.061103,45.777196,18.060708,45.776133,18.060355,45.775182)));
    insert into varos values (622732,'Vejti','Tancsics Mihaly utca',MDSYS.SDO_GEOMETRY(2002,NULL,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),MDSYS.SDO_ORDINATE_ARRAY(17.964469,45.809845,17.964149,45.809448,17.9641,45.809356,17.964009,45.809186,17.964004,45.808933,17.964007,45.808886,17.964169,45.808335,17.964781,45.807061,17.965233,45.806119,17.965492,45.805637,17.965682,45.805283,17.965802,45.805063,17.965932,45.804825,17.966221,45.804298)));
    insert into varos values (629498,'Pisks','5821',MDSYS.SDO_GEOMETRY(2002,NULL,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),MDSYS.SDO_ORDINATE_ARRAY(17.912804,45.80585,17.913105,45.805645,17.922503,45.803835,17.935384,45.803584)));
    -- Insert metadata record
    insert into USER_SDO_GEOM_METADATA values('VAROS','GEOMETRY',MDSYS.SDO_DIM_ARRAY( MDSYS.SDO_DIM_ELEMENT('Lon',16,23,0.00000001),MDSYS.SDO_DIM_ELEMENT('Lat',45.5,48.8,0.00000001)),NULL);
    -- Commit
    commit;
    -- Create spatial index
    CREATE INDEX VAROS_INDEX ON VAROS(GEOMETRY) INDEXTYPE IS MDSYS.SPATIAL_INDEX PARAMETERS('SDO_LEVEL=10 SDO_NUMTILES=8');
    -- Test steps:
    -- Select records with not 'nincs neve'
    select gmiprimarykey,tnev,nev
         from varos
         where nev <> 'nincs neve';
    -- It fetches 3 records     
    -- 615484,Kisszentmarton,58131
    -- 622732,Vejti,Tancsics Mihaly utca
    -- 629498,Pisks,5821
    -- Right.
    -- Embed the above select statement as a subselect to a nearest-neighbour spatial query.
    -- It is requested to return the 3 nearest records ('sdo_num_res=3').
    select gmiprimarykey,tnev,nev
         from ( select gmiprimarykey,tnev,nev,geometry
                   from varos
                   where nev <> 'nincs neve'
              ) y
         where mdsys.SDO_NN(y.geometry,mdsys.sdo_geometry(2001,NULL,mdsys.sdo_point_type(18,45.5,0),NULL,NULL),'sdo_num_res=3')='TRUE';
    -- It is expected to return 3 records (the same ones as above), but it returns only 1 single record
    -- 615484,Kisszentmarton,58131
    -- Wrong.
    It seems that Oracle executes the neaest neighbour spatial query BEFORE evaluating the inline view.
    Regards,
    Tamas Szecsy
    [email protected]

    Hi,
    The nearest neighbor query has to use the spatial index, and there is no way to filter the results and
    use the spatial index.
    So, in Oracle9i the SDO_NN tuning parameter SDO_BATCH_SIZE was introduced - what this does is
    keep streaming results from the SDO_NN query until some other condition is met.
    Rewriting your query to use SDO_BATCH_SIZE:
    select gmiprimarykey,tnev,nev
    from varos y
    where mdsys.SDO_NN(y.geometry,
    mdsys.sdo_geometry(2001,NULL,mdsys.sdo_point_type(18,45.5,0),NULL,NULL),
    'sdo_batch_size=5')='TRUE'
    and nev <> 'nincs neve'
    and rownum < 4;
    Two things about SDO_BATCH_SIZE:
    Cannot be used with SDO_NUM_RES
    Requires an R-tree index
    Also, you are using hybrid quadtree indexes. At this point in time, there are almost no situations where
    Oracle recommends using hybrid quadtree indexes (this is true in all versions of Oracle Spatial).
    As of Oracle9i, the recommendation is to use R-tree indexes (which work as well or better than
    quadtree indexes most of the time). Certainly if you require the incremental nearest neighbor functionality
    described above then you need to use an R-tree index.
    If you must use a quadtree index, then you will still have to use sdo_num_res, but you should try to set the
    number large enough so that any filtering leaves enough in the result set.

  • 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

  • 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.

  • Spatial Query with multiple geometries from 2 tables

    Hi,
    I'm using Oracle 8.1.7. I am trying to do a spatial query on two tables with multiple geometries. There are two spatial tables. One made up of points and one made up of polygons. There are 829551 rows in the table of points and 1817795 rows in the table with polygons...
    I want to find all polygons where one of this points is within it...
    This query is pretty intensive querying two large spatial tables against each other and so I need to find the most efficient way of running this query. I've been running variations of my query for the last two week and every time it's bombed out with various errors after 12-24 hrs processing like out of memory, out of tablespace, out of processing, invalid index etc etc etc. I need to get this query run asap... Any tips would be gratefully appreciated..
    For the session running the query I've allocated 16M sort area with
    ALTER SESSION SET SORT_AREA_SIZE=16777216;
    Below is the query I'm running... How can I improve this please? BTW PARCEL_OVERLAPS contains the points and TP$_PARCEL_AREAS the polygons.
    SELECT lu.LNU_PARCEL_ID
         FROM
              seventy.PARCEL_OVERLAPS po,
              imap_topol.TP$_PARCEL_AREAS pa,
              TP$_PARCEL_CENTROID_AREA pca,
              TDCR_LAND_UNIT lu
         WHERE
              SDO_FILTER(po.geometry, pa.area,
              'querytype=WINDOW') = ’TRUE’ and
              sdo_within_distance(po.geometry,pa.area,'distance=0')='TRUE' and
              pa.delete_date is null and
              Lu.LNU_LAND_UNIT_UNIQUE_NUM = pca.CENTROID_ID and
              pa.AREA_ID = pca.AREA_ID and
              pca.DELETE_DATE IS NULL and
              pa.DELETE_DATE IS NULL;

    Albert,
    Thanks for your reply and the tips you've given. The tp$_parcel_areas table will always be bigger so I've changed the order to sdo_within_distance(pa.area,po.geometry,'distance=0')='TRUE'. The requested counts for those queries are
    12:26:29 [email protected]:SQL> select count(*)
    13:46:22 2 from seventy.PARCEL_OVERLAPS;
    COUNT(*)
    612
    13:48:12 [email protected]:SQL> select count(*)
    13:48:17 2 from imap_topol.TP$_PARCEL_AREAS pa,
    13:48:21 3 TP$_PARCEL_CENTROID_AREA pca
    13:48:21 4 where pca.DELETE_DATE IS NULL
    13:48:21 5 and pa.DELETE_DATE IS NULL
    13:48:21 6 and pa.AREA_ID = pca.AREA_ID;
    COUNT(*)
    1310665
    There was no reason for both filter and within_distance. I did try use the anyinteract but for some reason that does not return the desired results(I've added one id row as a test to make sure it returns desired results). Plus Oracle have recomended using the within distance for better performance..
    so the explan plan for
    14:38:37 [email protected]:SQL> EXPLAIN PLAN FOR
    14:38:50 2 SELECT lu.LNU_PARCEL_ID
    14:38:50 3 FROM
    14:38:50 4 seventy.PARCEL_OVERLAPS po,
    14:38:50 5 imap_topol.TP$_PARCEL_AREAS pa,
    14:38:50 6 TP$_PARCEL_CENTROID_AREA pca,
    14:38:50 7 TDCR_LAND_UNIT lu
    14:38:50 8 WHERE
    14:38:50 9 sdo_within_distance(pa.area,po.geometry,'distance=0')='TRUE' and
    14:38:50 10 pa.delete_date is null and
    14:38:50 11 Lu.LNU_LAND_UNIT_UNIQUE_NUM = pca.CENTROID_ID and
    14:38:50 12 pa.AREA_ID = pca.AREA_ID and
    14:38:50 13 pca.DELETE_DATE IS NULL and
    14:38:50 14 pa.DELETE_DATE IS NULL;
    is
    Plan Table
    | Operation | Name | Rows | Bytes| Cost | Pstart| Pstop |
    | SELECT STATEMENT | | 4G|32920G| 547M| | |
    | NESTED LOOPS | | 4G|32920G| 547M| | |
    | MERGE JOIN | | 547M| 2029G| 230124 | | |
    | SORT JOIN | | 1M| 36M| 85014 | | |
    | MERGE JOIN | | 1M| 36M| 50019 | | |
    | SORT JOIN | | 1M| 17M| 21650 | | |
    | TABLE ACCESS FULL |TP$_PARCE | 1M| 17M| 485 | | |
    | SORT JOIN | | 1M| 22M| 28369 | | |
    | TABLE ACCESS FULL |TDCR_LAND | 1M| 22M| 2127 | | |
    | SORT JOIN | | 42K| 160M| 145111 | | |
    | TABLE ACCESS FULL |TP$_PARCE | 42K| 160M| 12697 | | |
    | TABLE ACCESS FULL |PARCEL_OV | 817 | 3M| 1 | | |
    14:43:14 [email protected]:SQL> explain plan for
    14:43:23 2 SELECT pa.AREA_ID
    14:43:23 3 FROM seventy.PARCEL_OVERLAPS po,
    14:43:23 4 imap_topol.TP$_PARCEL_AREAS pa
    14:43:23 5 WHERE SDO_RELATE(po.geometry, pa.area,'mask=ANTINTERACT querytype=WINDOW') = 'TRUE'
    14:43:23 6 and pa.DELETE_DATE IS NULL;
    Plan Table
    | Operation | Name | Rows | Bytes| Cost | Pstart| Pstop |
    | SELECT STATEMENT | | 6M| 50G| 10M| | |
    | NESTED LOOPS | | 6M| 50G| 10M| | |
    | TABLE ACCESS FULL |PARCEL_OV | 817 | 3M| 1 | | |
    | TABLE ACCESS FULL |TP$_PARCE | 850K| 3G| 12697 | | |
    14:45:03 [email protected]:SQL> explain plan for
    14:45:04 2 SELECT pa.AREA_ID
    14:45:05 3 FROM seventy.PARCEL_OVERLAPS po,
    14:45:05 4 imap_topol.TP$_PARCEL_AREAS pa
    14:45:05 5 WHERE SDO_RELATE(pa.area, po.geometry,'mask=ANTINTERACT querytype=WINDOW') = 'TRUE'
    14:45:05 6 and pa.DELETE_DATE IS NULL;
    Plan Table
    | Operation | Name | Rows | Bytes| Cost | Pstart| Pstop |
    | SELECT STATEMENT | | 6M| 50G| 863554 | | |
    | NESTED LOOPS | | 6M| 50G| 863554 | | |
    | TABLE ACCESS FULL |TP$_PARCE | 850K| 3G| 12697 | | |
    | TABLE ACCESS FULL |PARCEL_OV | 817 | 3M| 1 | | |
    --------------------------------------------------------------------------------

  • Poor performance with Oracle Spatial when spatial query invoked remotely

    Is anyone aware of any problems with Oracle Spatial (10.2.0.4 with patches 6989483 and 7003151 on Red Hat Linux 4) which might explain why a spatial query (SDO_WITHIN_DISTANCE) would perform 20 times worse when it was invoked remotely from another computer (using SQLplus) vs. invoking the very same query from the database server itself (also using SQLplus)?
    Does Oracle Spatial have any known problems with servers which use SAN disk storage? That is the primary difference between a server in which I see this poor performance and another server where the performance is fine.
    Thank you in advance for any thoughts you might share.

    OK, that's clearer.
    Are you sure it is the SQL inside the procedure that is causing the problem? To check, try extracting the SQL from inside the procedure and run it in SQLPLUS with
    set autotrace on
    set timing on
    SELECT ....If the plans and performance are the same then it may be something inside the procedure itself.
    Have you profiled the procedure? Here is an example of how to do it:
    Prompt Firstly, create PL/SQL profiler table
    @$ORACLE_HOME/rdbms/admin/proftab.sql
    Prompt Secondly, use the profiler to gather stats on execution characteristics
    DECLARE
      l_run_num PLS_INTEGER := 1;
      l_max_num PLS_INTEGER := 1;
      v_geom    mdsys.sdo_geometry := mdsys.sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,0,45,45,90,0,135,45,180,0,180,-45,45,-45,0,0));
    BEGIN
      dbms_output.put_line('Start Profiler Result = ' || DBMS_PROFILER.START_PROFILER(run_comment => 'PARALLEL PROFILE'));  -- The comment name can be anything: here it is related to the Parallel procedure I am testing.
      v_geom := Parallel(v_geom,10,0.05,1);  -- Put your procedure call here
      dbms_output.put_line('Stop Profiler Result = ' || DBMS_PROFILER.STOP_PROFILER );
    END;
    SHOW ERRORS
    Prompt Finally, report activity
    COLUMN runid FORMAT 99999
    COLUMN run_comment FORMAT A40
    SELECT runid || ',' || run_date || ',' || run_comment || ',' || run_total_time
      FROM plsql_profiler_runs
      ORDER BY runid;
    COLUMN runid       FORMAT 99999
    COLUMN unit_number FORMAT 99999
    COLUMN unit_type   FORMAT A20
    COLUMN unit_owner  FORMAT A20
    COLUMN text        FORMAT A100
    compute sum label 'Total_Time' of total_time on runid
    break on runid skip 1
    set linesize 200
    SELECT u.runid || ',' ||
           u.unit_name,
           d.line#,
           d.total_occur,
           d.total_time,
           text
    FROM   plsql_profiler_units u
           JOIN plsql_profiler_data d ON u.runid = d.runid
                                         AND
                                         u.unit_number = d.unit_number
           JOIN all_source als ON ( als.owner = 'CODESYS'
                                   AND als.type = u.unit_type
                                   AND als.name = u.unit_name
                                AND als.line = d.line# )
    WHERE  u.runid = (SELECT max(runid) FROM plsql_profiler_runs)
    ORDER BY d.total_time desc;Run the profiler in both environments and see if you can see where the slowdown exists.
    regards
    Simon

  • Spatial query on join view in another schema

    Background:
    I have a schema with tables containing four spatial columns per table. I have a second schema that contains join views of the tables in the first schema. The join view consists of the attributes and any other tabular data that is joined via foreign key to non-spatial tables and one of the four geometry columns. I have a third schema that owns no database objects of its own, but has select privilege to the second schema's view objects.
    We are using Oracle 10.2.0.2 on a windows platform.
    This worked in 9i, the problem only presented itself when we migrated to 10g.
    Problem:
    When I run a spatial query on a join view in the second schema(the schema that owns the object), it runs and returns results in about a second. When I run the exact same query in the third schema it routinely takes 20-30 seconds.
    Here is the query that I run in both schemas with varying query times:
    SELECT COUNT(*)
    FROM two.join_view_a A
    WHERE (MDSYS.SDO_FILTER(A.GEOM, SDO_GEOMETRY(2003,8307,NULL,SDO_ELEM_INFO_ARRAY(1,1003,3),SDO_ORDINATE_ARRAY(26.6396,26.5708,43.346,34.4083)),'QUERYTYPE=WINDOW')='TRUE');
    Question:
    Why does this happen?
    What can I do to fix this problem?
    Thanks,
    John

    Have a read of this posting: Oracle spatial view runing slow as different user
    There are details there about the 'optimizer_secure_view_merging' parameter and the effect it can have on cross schema views in 10.2

  • 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 optimizing

    hi, there.
    I am working Oracle Spatial 9.0.1 and I have a problem about the
    performance of spaital query, can someone help me resolve it?
    /*query 1*/
    select t1.line_seg
    from spatial_list_Traj
    where sdo_within_distance(convert_trajseg_to_lineseg
    (t1.line_seg), MDSYS.SDO_GEOMETRY(2003, NULL, NULL,
    MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 3), MDSYS.SDO_ORDINATE_ARRAY
    (212.117, 352.613, 221.617, 362.708)), 'querytype=filter
    distance=0.5') = 'TRUE';
    /* query 2*/
    select t1.line_seg
    from spatial_list_traj
    where object_id = 1 and sdo_within_distance
    (convert_trajseg_to_lineseg(t1.line_seg), MDSYS.SDO_GEOMETRY
    (2003, NULL, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 3),
    MDSYS.SDO_ORDINATE_ARRAY(212.117, 352.613, 221.617,
    362.708)), 'querytype=filter distance=0.5') = 'TRUE';
    there are about 120,000 rows in the spatial_list_Traj table and
    query 1 takes only 1 second to finish, which is a good result
    but if I add another condition, like query 2, the time cost is
    still 1 second. I thought it can be much faster since there is
    only 48 rows whose object_id is 1. what I expected it to do was
    for the optimizer to filter out the rows that match
    the 'object_id = 1' criteria and then do a spatial query on the
    filtered data.
    PS: there are two indices--a b-tree index on column 'object_id'
    and of course, a functional spatial index on column 'line_seg',
    which is a R-tree.
    thanks in advance
    Hu Cao

    Hi Hu,
    The second query is probably not using the spatial index. The
    spatial index indexes the whole table based on spatial
    relationships, so even though you may have filtered out all but
    48 rows, the spatial index has to be applied to all of the rows.
    In this case, it is probable that all of the rows returned with
    object_id=1 are being geometrically compared with your query
    window, which may account for the extra time.
    You may want to try a hint to tell the optimizer not to use the
    index on object_id, i.e.
    SELECT /*+NO_INDEX(spatial_list_traj object_id_index_name)*/
    Hope this helps,
    dan

Maybe you are looking for

  • How to turn off the Charms Bar in Windows 8.1

    I have a new HP laptop with Windows 8.1. I absolutely HATE the charms bar. It's very annoying. I have turned off the corner function so the Charms bar no longer pops up if I swipe the corner edges, however, it still pops up randomly. I'll be typing a

  • Error when modifying VM Memory - "Invalid minimum memory amount"

    Good day, I am trying to modify a virtual machine's static memory setting using VMM 2012 R2 with UR 2.  The VM is running on a Hyper-V 2012 R2 host cluster.  Whether I use the VMM GUI or attempt to issue the command via VMM Command Shell, I get the s

  • Sql report: current pagination

    hello! i have a sql report with partial page refresh enabled and pagination schema "Row Ranges 1-15 16-30 in select list (with pagination)". is it somehow possible to get the current page of the sql report (via javascript)? thx! best regards, christi

  • Enhancements in SAP HR

    Can anyone please provide me the material for enhancements in SAP HR.

  • Ringback Tones on more than one phone

    I purchased many Ringback Tones for my phone which is the main phone number and administrator of account. I tried loading some onto another phone on my account and even though I can find and hit the number for my wife's phone, after I make a choice f