Tune oracle spatial index

Hi everyone,
how to tune spatial index in oracle? Pls advice
Thanks in Advance

That's a very open ended question. When posting questions on this forum you'll get better results if you have very specific questions. So do you have a specific spatial query which isn't performing well? If so then post as much information as you can about it.
- Exactly what version of Oracle database?
- What is the SQL query you're running - if possible include the explain plan
- What is your expected response time for the query?
- How much data is in the table and what kind of data is it
- Is possible provide some information about the use case behind the query you're running.
There are various techniques available to make spatial queries perform as you'd expect, but I'm not going to waste my time going through them here until you provide some useful information.
I'd recommend having a look at this presentation for some advice:
http://download.oracle.com/otndocs/products/spatial/pdf/ow_2009/spatial_oow09_tuning_and_best_practices2.pdf
Also have a look at this:
http://download.oracle.com/otndocs/products/spatial/pdf/spatial_wp09_bestprac.pdf

Similar Messages

  • Oracle Spatial Index Advisor

    Have tried to use subject and got an error when adding the table to analyze.
    Error: Server object could not be created: server object could not be initialized: Non supported character set: oracle-character-set-171.
    What's issue of this error? Does anyone know?

    Hi Igor,
    Not sure what the problem is.
    This could be an NLS issue.
    You might want to log a bug against
    the Spatial Index Advisor with a small dump
    file of your layer.
    Also, can you make sure your entries
    in USER_SDO_GEOM_METADATA are correct?
    Thanks.
    Dan

  • Oracle spatial Indexing

    Hi Guru's
    I am newby to Oracle spatial. Working as Database Admin.
    I want information about spatial indexing like creation, maintenence ..etc.
    It would be a great help if you can refer any relevant documents, articles or presentations.
    Thanks in advance
    Cheers
    Antony

    Welcome Antony
    First place to start is the user documentation:
    http://download.oracle.com/docs/html/B14255_01/toc.htm
    start reading on the indexing here:
    http://download.oracle.com/docs/html/B14255_01/sdo_intro.htm#sthref98
    As an alternative/added value the Pro Oracle Spatial book is also a very good reference.
    http://www.oracle.com/technology/products/spatial/htdocs/pro_oracle_spatial.html
    there is also a second version for 11g.
    For the maintenance, certainly from a DBA point of view, it is worthwhile looking at Radius Check. The lightweight free version offers an easy overview on the geometry tables, their metadata and their spatial indexes.
    The professional version also gives Checks for invalid geometries with fixing capabilities.
    On the Oracle Spatial Download page (http://www.oracle.com/technology/products/spatial/htdocs/spatial_partners_downloads.html), you can find the link second at the top to the webpage of Radius Check (http://www.1spatial.com/products/radius_check/index.php).
    Good Luck
    Luc
    Edited by: lucvanlinden on Nov 14, 2008 8:45 AM

  • Oracle Spatial 8.1.7 r-tree indexes

    I don't think this problem is specific to r-tree indexes vs. quad-tree.
    Even though I specify a tablespace other than the SYSTEM tablespace in Oracle Spatial Index Advisor when creating r-tree indexes, the index is still created in the SYSTEM tablespace. I don't want my spatial indexes in the SYSTEM tablespace!
    select tablespace_name from user_indexes where index_name = 'GPS_IDX';
    TABLESPACE_NAME
    SYSTEM
    Here is the sql statement that Spatial Index Advisor constructed:
    create index gis.gps_idx on gis.gps (geometry) indextype is mdsys.spatial_index parameters ('sdo_indx_dims=2');
    I was not able to issue this sql from worksheet with the tablespace option added. Is there a way to do that?
    In Spatial Index Advisor, if I don't select the geometry column, then the sql is constructed with the tablespace option added, but when I select the geometry column, it removes it from the sql.
    Can anybody shed some light on how to do this?
    thanks
    Dave

    Spatial creates an index entry in the system tablespace but realy creates the spatial index in the tablespace you gave it. To verify it execute the select:
    select table_name,tablespace_name
    from user_tables
    where table_name like 'spatial_table%';
    It will return your table_name plus the spatial index table created for it.
    The table_name will look something like this:
    spatial_table_SX_FL10$.
    spatial_tables beeing your spatial table.
    You can query the same for the indexes built on that previous table.
    select index_name,tablespace_name
    from user_indexes
    where table_name = 'SPATIAL_TABLE_SX_FL10$';
    The two index names would look like:
    spatial_table_sx_fl10$B1
    spatial_table_sx_fl10$B2
    They should be created in the tablespace mentionned in your tablespace clause when creating the spatial index.
    Hope this helps

  • Using Java with Oracle Spatial

    I am using the JDBC (Java classes dowloaded from
    technet.oracle.com - (sdoapi.zip)) together with Oracle Spatial
    8.1.6. I am writing a collection of Linestrings into Oracle
    Spatial using the supplied java classes(sdoapi.zip). I use the
    function createGeometryCollection(myCollection)to write the
    Linestring collection to Oracle Spatial and they are written to
    the database without error. However, when I try to read the
    object back I get the following error:
    Exception in thread "main"
    oracle.sdoapi.geom.InvalidGeometryException
    at oracle.sdoapi.adapter.AdapterSDO.importGeometry
    (AdapterSDO.java:101)
    at
    MapInfoToOracleSpatial.MapInfoToOracleSpatial.main
    (MapInfoToOracleSpatial.java:211)
    I do not have a listing of this code so can you please tell me
    what the error is (line of code) at line 211. Also, when I use
    the Oracle Spatial Index Advisor to view the spatial data, it
    only displays a quarter of the data. When I use MapInfo to view
    it's equivalent TAB (Table) file it views correctly all the
    data.
    I can't understand why this is happening because the writing to
    oracle and creation of each individual linestring does not
    throw an error. It is only when I try to read back larger
    objects from the database (2500 points) that it gives an error.
    Is there a limitation on the size one can create linestrings?
    Thanks
    Regards
    Stephen Syrett
    Mobile Telecommunications Network
    (MTN) South Africa

    Latest Oracle Openworld Spatial/MapViewer activities list:
    http://www.oracle.com/us/products/database/options/spatial/ssLINK/oow10-focuson-spatial-169204.pdf
    thanks
    LJ

  • Function-based spatial indexes

    hello,
    I'm using a function-based spatial index, which I've set up in a way similar to Oracle's examples in the Spatial documentation. Here's the basic idea:
    create table places (
    place_id not null
    primary key,
    latitude number,
    longitude number
    -- This function is used to create an MDSYS.SDO_GEOMETRY object
    -- as part of the Oracle Spatial indexing of the latitude and
    -- longitude.
    create or replace function get_long_lat_pt(
    longitude in number,
    latitude in number)
    return MDSYS.SDO_GEOMETRY deterministic
    is
    begin
    if latitude is null or longitude is null
    then
    return null;
    else
    return mdsys.sdo_geometry(2001, 8307,
    mdsys.sdo_point_type(longitude, latitude, NULL), NULL, NULL);
    end if;
    end;
    show errors
    INSERT INTO USER_SDO_GEOM_METADATA
    VALUES ('PLACES', 'schema_name.GET_LONG_LAT_PT(LONGITUDE,LATITUDE)',
    MDSYS.SDO_DIM_ARRAY(
    MDSYS.SDO_DIM_ELEMENT('Longitude', -180, 180, 0.00000005),
    MDSYS.SDO_DIM_ELEMENT('Latitude', -90, 90, 0.00000005)),
    8307
    -- Create Oracle Spatial function-based index
    CREATE INDEX places_long_lat_idx ON places(get_long_lat_pt(longitude, latitude))
    INDEXTYPE IS mdsys.spatial_index PARAMETERS('layer_gtype="POINT"');
    All of this works just fine. But then I try to do a nearest neighbor calculation:
    select /*+ INDEX(places places_long_lat_idx) */ place_id
    FROM places WHERE
    SDO_NN(
    get_long_lat_pt(longitude,latitude), -- table values
    get_long_lat_pt(-71.1482, 42.3367), -- an arbitrary point
    'sdo_num_res=2') = 'TRUE'
    and I get this:
    ERROR at line 1:
    ORA-13249: SDO_NN cannot be evaluated without using index
    ORA-06512: at "MDSYS.MD", line 1723
    ORA-06512: at "MDSYS.MDERR", line 17
    ORA-06512: at "MDSYS.PRVT_IDX", line 27
    It's as though Oracle isn't using the function-based index inside my SDO_NN call, even with a INDEX hint. I am stumped.
    Just for kicks I tried to do a query using SDO_FILTER instead. I get:
    ERROR at line 1:
    ORA-13268: error obtaining dimension from USER_SDO_GEOM_METADATA
    ORA-06512: at "MDSYS.MD", line 1723
    ORA-06512: at "MDSYS.MDERR", line 8
    ORA-06512: at "MDSYS.SDO_3GL", line 365
    I am using Oracle 9.0.1.0.0, and I set QUERY_REWRITE_ENABLED=TRUE and QUERY_REWRITE_INTEGRITY=TRUSTED as noted in the Spatial documentation.
    Any clues?
    Thanks,
    Greg

    Greg,
    The only times I have seen this error is when the
    two parameters you mention are not set properly for the session.
    I have a feeling that the parameters (QUERY_REWRITE_ENABLED,
    and QUERY_REWRITE_INTEGRITY) are not getting the right values.
    Can you verify this by doing a
    show parameter QUERY_REWRITE_INTEGRITY
    and
    show parameter QUERY_REWRITE_ENABLED
    from the session from where you are trying to execute
    the Spatial operator.
    Or you can try setting them for the session by
    alter session set parameter=value
    to see if it makes a difference.
    thanks
    siva

  • Can Oracle be forced to use the spatial index for sdo_filter in combination with an or clause? Difference between Enterprise and SE?

    We’re seeing the following issue: sql - Can Oracle be forced to use the spatial index for sdo_filter in combination with an or clause? - Stack Overflow (posted by a colleague of mine) and are curious to know if this behaviour is due to a difference between standard and enterprise, or could we doing something else wrong in our DB config.?
    We have also reproduced the issue on the following stacks:
    Oracle SE One 11.2.0.3 (with Spatial enabled)
    Redhat Linux 2.6.32-358.6.2.el6.x86_64 #1 SMP Thu May 16 20:59:36 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
    11.2.0.3.0 Standard Edition and 11.2.0.4.0 Standard Edition (both with Spatial enabled)
    Microsoft Windows Server 2003R2 Standard x64 Edition
    However, the SQL works fine if we try it on Oracle 11.2.0.3.0 *Enterprise* Edition.
    Any help or advice would be much appreciated.
    Kindest Regards,
    Kevin

    In my experience sdo_filter ALWAYS uses the spatial index, so that's not the problem. Since you did not provide the explain plans, we can't say for sure but I think yhu is right: Standard Edition can't use the bitmap operations, and thus it'll take longer to combine the results of the two queries (because the optimizer will surely split this OR up in two parts, then combine them).
    BTW: when asking questions about queries here, it would be nice if you posted the queries here as well, so that we do not have to check another website in order to see what you are doing. Plus it will probably get you more answers, because not everyone can be bothered to click on that link. It would also have been nice if you had posted your own answer on the other post here as well, because my recommendation would have been to use union all - but since you already found that out for yourself my recommendation would have been a little late.

  • Oracle 10g EE - Spatial Index, C Interfacing & Custom C Functions

    Hi everyone,
    I'm doing a research project concerning indexing and I'd like to do some testing using Oracle DB.
    My questions are:
    1) I've noticed here (http://www.oracle.com/database/product_editions.html) that Spatial is not included in EE, is this just the complex spatial functions? Is the R-tree (or some other spatial index) still available for simple queries?
    2) I've read that Pro*C is the simplest way to use Oracle from C, however Pro*C does not exist in 10g, only OCI. Is there a simpler way to use Oracle from C other than OCI?
    3) How do I go about creating custom functions which are written in C (for speed reasons)?
    If not all of these are possible in EE, which version of Oracle would I need?
    Thanks heaps,
    Martin.

    From the binaries point of view Spatial is included in the Enterprise Edition, the fact that it says it is an option means you have to buy a license additional from the enterprise Edition license to be able to use it.
    You can find several demos based on MapViewer which are written in java, so IMO Pro*C is not the best suitable way to start working with Spatial Data, I suggest you to consider Java instead.
    ~ Madrid
    http://hrivera99.blogspot.com/

  • Oracle 9 spatial index export/import

    Hi,
    when exporting/importing a user via exp/imp I encounter a problem with the numeric characters encoding during creation of a spatial index.
    Imp tool produces script like this:
    "BEGIN "
    "execute immediate 'INSERT INTO USER_SDO_GEOM_METADATA values (''POINTS'',''GEOMETRY'',mdsys.SDO_dim_array(MDSYS.SDO_DIM_ELEMENT(''X'',50000000,160000000,,005),MDSYS.SDO_DIM_ELEMENT(''Y'',450000000,600000000,,005)),,005) ' ; "
    "COMMIT; END;"
    Problem is with wrong representation of the numeric value '0.005' as ,005.
    Originally, the index was created via
    INSERT INTO USER_SDO_GEOM_METADATA
    VALUES (
    'points',
    'geometry',
    MDSYS.SDO_DIM_ARRAY(
    MDSYS.SDO_DIM_ELEMENT('X',-125000000,-115000000, '0.005'),
    MDSYS.SDO_DIM_ELEMENT('Y', 30000000, 42100000, '0.005')
    NULL
    Any hints how to reimport the index correctly?
    Thanks,
    Bogart

    You might need to set the NLS_LANG environment variable to get character set conversion done on import (I don't know this unfortunately - it has never been a problem for me).
    There is a section on character set conversions in the utilities manual.

  • Oracle materialized view + spatial index

    Hello,
    i faced with problem when i create spatial index on materialized view.
    I create materialized view on 2 table which contains spatial geometrys.
    create materialized view mv_geom as
    select g.nid, g.geometry
    from geom1
    union all
    select select g.nid, g.geometry
    from geom2
    i created spatial index - all works fine, but when i try to drop table, i get exception "ORA-04020"...
    Materialized view become invalid but don't drop from database.
    SQL> drop materialized view mv_geom;
    Materialized view dropped
    But object does not drop
    select * from all_objects z where z.OBJECT_NAME = 'geom1'
    and z.OBJECT_TYPE ='MATERIALIZED VIEW'
    Any ideas?
    Thank's for help!

    I don't quite follow you. Do you mean that after you dropped mv "mv_geom".
    you expect that the base table "geom1" should be dropped?

  • Spatial index tunning

    Hi, everyone
    I have a spatial database having tables with millions of data. Currently, the performane is very slow. pls gve some solutions for tuning the spatial index.
    Thanks in Advance

    Albin,
    How about you tell us what you have done wrt your setup so people can see what you have done that you think is wrong.
    Supply
    * Spatial index creation statements
    * Information on table sizes
    * Have geometry columns:
    - more than one geometry type (eg polygons and linestrings)
    - been validated
    regards
    Simon

  • Loading shapefiles into Oracle Spatial

    Fellow Oracle Spatiallers!
    Currently we edit Oracle Spatial data by checking data out into a shapefile,
    making our changes off-line, and reloading the shapefile back into Oracle.
    Instead of using the Oracle Spatial supplied tool, we decided to purchase
    a utility called the "Spatial Loader" from a company called Geometry Pty Ltd
    (http://www.geometryit.com). There are a number of reasons why we decided to
    go that way which might become evident from the command line parameters of
    this utility:
    Usage: Shp2Spt [Arguments] [Options]
    OR
    Usage: Java com.geometryit.spatialloader.oracle.AdvancedJavaSpatialTranslator [Arguments] [Options]
    [Arguments] must specify these values:
    -o create
    type of operation to perform
    create creates a new table, must not exist already
    recreate creates a new table, may exist already
    init drops existing table, creates a new one
    append appends data onto existing table
    -f <shape_file>
    the shape file or project to translate
    -l <table,column>
    target table and column for the geometry data
    -D <database>
    target database name
    -u <username>
    username for RDBMS
    -p <password>
    password for RDBMS
    [Options] values are not necessarily required:
    -s <server_name>
    name of server with database
    -port <port_number>
    the port to connect to on the server
    -ufi <column_name>
    specify the name of the UFI field (unique ID)
    -seq <sequence_name>
    specify the sequence to use for the spatial data unique IDs
    -a none
    attributes mode
    none no attributes will be transferred
    all all attribtues will be transfered as found
    file= file containing lines of the form:
    <shape_attribute><space/tab><rdbms_column>
    where
    <shape_attribute> selects the column to be output
    <rdbms_column> name of the column in RDBMS
    -srid <id>
    specify the Spatial Reference ID for the spatial data
    (this must be set to use Spatial Reference Transformations)
    -i [<level>] or -i rtree
    create an index for the generated table
    the <level> parameter is an optional integer
    representing the depth of the quadtree created
    if rtree is specified, the index created will be
    an rtree
    -c <commit_interval>
    number of rows to commit after
    -t <tolerance>
    tolerance value for metadata
    -r none
    used to determine number of decimal places to round vertices to
    if you use the tolerance-parameter option, specify the -t parameter before -r
    -igc
    ignore geometry collections
    -sgc
    split geometry collections
    -sgd f
    split geometry direction [forward | reverse]
    -update-metadata <true/false>
    update the Oracle Spatial Metadata table after loading data
    -validate <true/false>
    perform Oracle Spatial validation after loading data
    -v
    verbose mode on
    -h or -?
    display this help message
    The main things I like about this tool are:
    1. One step (no conversion to sqlloader form followed by a call to the sqlloader).
    2. The ability to round the coordinates of the shapes in the shapefile by applying
    the XY tolerance values held in the SDO_GEOM_METADATA table.
    This is quite important because our editing package - due to double/single precision
    issues - can actually move coordinates but those movements are sub the precision of
    the actual data. By rounding to the nominate precision we can detect situations where
    no actual change to the shape (and its attributes) was made and thus not create superfluous
    revisions within the database.
    3. It will correctly re-wind the coordinates of the outer/inner shells of polygons. This is
    important as ESRI shapefiles are agnostic on the winding order: an outer shell coordinates
    can be listed in either clockwise or anti-clockwise order.
    4. You can specify the primary key (UFI) column (numeric) and an Oracle Sequence number such
    that each new shape loaded can have its UFI assigned from that sequence.
    Because of this flexibility, and the excellent support (it is a purchasable product) from the
    developers, I can heartily recommend this loader to fellow Spatiallers. It is worth every
    penny I spent on it. Try the free version on their website and if, like me, you like it,
    purchase it!
    regards
    Simon

    Hi Shuan,
    As part of the zip file created for the next training course to be posted for Oracle Spatial on OTN (within the next few weeks) there is a free (unsupported, undocumented) version of a shape to sdo converter. This should work, but it is unsupported. It will create a layer that then needs to be migrated into 8.1.6 format.
    If you need it quite soon send email to [email protected] and I can get it to you.
    Hope this helps,
    dan

  • Help define the requirements for an Oracle Spatial management tool

    Hi,
    We are developing a tool that, we hope, will be indispensable for all Oracle Spatial and Locator dbas/users. We've released version 1.0, but we need your help to define the requirements for the next version.
    What features would you like to have in a management tool for your spatial databases?
    The features we've got so far:
    1. Viewing of vector data in a map + attributes
    2. Loading from shapefiles
    3. Exporting to shapefiles
    4. Validating metadata, indexes and spatial data.
    We are adding editing of vectors in the next version - basic stuff for add, update and delete.
    But there must be a lot more. What do you find difficult to do in Oracle Spatial/Locator? What would you like in a tool such as this?
    Any feedback either to myself or the forum is much appreciated.
    cheers,
    Andrew
    [email protected]
    PS If you like to have a look at what we have done so far, go to http://www.geometryit.com/products/spatialConsole.php

    Andrew knows what I have asked for but for others to think about and to start
    the ball rolling, here's what they are:
    1. Ability to enter own SQL commands but with PARAMETERS for attributes
    and shapes as in the following examples:
    SELECT ...
    FROM my_spatial_table a
    WHERE a.ATTRIBUTE = :attr
    AND MDSYS.SDO_RELATE(a.shape,:polygon,'mask=anyinteract') = 'TRUE'
    When executed the attribute value is asked for via a input box (data type?)
    and the user is asked to define the SDO_GEOMETRY for the :polgygon parameter via mouse clicks on the screen.
    Similarly, this would work for INSERT, UPDATE and DELETE...
    INSERT INTO my_spatial_table (shape) values(:polygon)
    The data type of an attribute parameter could be determined in two ways:
    a) By querying the Oracle catalog;
    b) By using a "PARAMETERS" command before the query as follows
    PARAMETERS name type [(size)] [, name type [(size)] ...]
    The PARAMETERS declaration has these parts:
    name     The name of the parameter.
    type     The type of the parameter.
    size     The size of the parameter in characters or bytes.
    2. When executing an SQL SELECT statement I would like the tool
    to suggest the HINTS that are needed to improve performance.
    3. Following on from 2, I would like to Tick an option that would return the
    EXPLAIN PLAN that the query optimizer used when executing my query.
    4. The tool has to support ALL Oracle's spatial vector data types.
    5. It would be nice to be able to work with GeoRasters. Since Spatial Console
    imports/exports shapefiles why not the same for rasters. However, the problem
    with supporting foreign data formats is WHERE DO YOU STOP!!!!!
    6. You could allow for the styling of the Spatial Console to be stored in the MapViewer catalogs or use the MapViewer catalogs when styling an Sdo_Geometry if it exists (I note that your tool extracts the SDO_METADATA
    why not the MapViewer metadata as well)?
    regards
    S.

  • Spatial Index and XA transaction

    Hi all,
    I have problem with spatial index in XA transaction.
    java.sql.SQLException: ORA-29875: failed in the execution of the ODCIINDEXINSERT routine
    ORA-29400: data cartridge error
    ORA-14450: attempt to access a transactional temp table already in use
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 623
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 227
    My configuration Java 5, Tomcat 5.5, UserTransaction manager Bitronix.
    The problem disappears after dropping spatial index.
    sql statement:
    INSERT INTO ICING_SPATIAL.MAP_ISSUES ( FEATURE_ID, GEOMETRY, AUTHOR_ID, ISSUE_ID, ISSUE_STATUS, LANGUAGE, SOURCE, TEXT) VALUES ( ? ,SDO_MIGRATE.TO_CURRENT( ? , ( SELECT DIMINFO FROM ALL_SDO_GEOM_METADATA WHERE OWNER = ? AND TABLE_NAME = ? AND COLUMN_NAME = ? ) ), ? , ? , ? , ? , ? , ? )
    Full stacktrace is:
    java.sql.SQLException: ORA-29875: failed in the execution of the ODCIINDEXINSERT routine
    ORA-29400: data cartridge error
    ORA-14450: attempt to access a transactional temp table already in use
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 623
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 227
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
    at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
    at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:212)
    at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:951)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1160)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3368)
    at oracle.jdbc.driver.OracleCallableStatement.executeUpdate(OracleCallableStatement.java:4245)
    All user transactions are commited or rollbacked because the DBA_2PC_PENDING is empty: SQL> select * from SYS.DBA_2PC_PENDING;
    no rows selected
    SQL>
    This problem occures regulary after any 2PC transaction has been rolledback. The next request causes this exception. Sometimes it appears after commit too, but I am able to reproduce it within ten or twenty requests.
    Has anybody had simillar problem?
    Thanks for any suggestions how to check what is going wrong.
    Regards,
    Zdenek Vrablik

    The problem is in Oracle Spatial.
    Oracle database don't support Temporary tables and XA transactions together. Oracle Spatial uses temporary tables.
    Possible solution (I am using)
    One database connection(nonXA) to read data and one connection(XA) to insedt/update/delete data including spatial data.

  • Creating a combined view of two spatially indexed tables

    Hi All,
    I'm using oracle 10g and C++ occi to store and retrieve data. I have two tables that are identical in structure, they have an SDO_GEOM column where I store lat/long/altitude info. When I store the data using a stored procedure, the data is put into the correct table. I now want to retrieve the data using a spatial operator - I use SDO_NN to retrive data within a given distance of a lat/long/altitude point. This works fine for a single or multiple tables as I use a stored function to give me the data back as an object. I now have a requirement to list all the data from both tables - I thought I could do this by creating a combined view but I understand this cannot be done with spatial data - I habe also tried using the join operator but I am having problems since the columns for each table are identical. Is there any workaround for this - the combined view will not have any spatial operators run on it, I just need to return each row (the spatial data can be returned as individual lat/long/alt instead of as a SDO_GEOM. A second idea I had would be to return all the data using a ref cursor - this works for a single table but I do not understand how I can open the cursor with a select from two tables with identical column names.
    Unfortunately it is a requirement that the tables are seperate so combining the two tables into one is not an option.
    Thanks in advance for any help anyone can offer,
    Cheers,
    Rob

    You can create a UNION ALL view:
    CREATE TABLE cola_markets_1 (
    mkt_id NUMBER PRIMARY KEY,
    name VARCHAR2(32),
    shape SDO_GEOMETRY);
    CREATE TABLE cola_markets_2 (
    mkt_id NUMBER PRIMARY KEY,
    name VARCHAR2(32),
    shape SDO_GEOMETRY);
    CREATE VIEW v1 AS
    SELECT * FROM cola_markets_1 UNION ALL SELECT * FROM cola_markets_2;
    If both tables have a spatial index on their shape column, a query plan will look
    like:
    explain plan for SELECT c.mkt_id, c.name FROM v1 c WHERE SDO_NN(c.shape, SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,3), SDO_ORDINATE_ARRAY(4,6, 8,8)) , 'sdo_num_res=1') = 'TRUE';
    0 SELECT STATEMENT     |           |
    1 VIEW               | V1          |
    2 UNION-ALL          |           |
    3 TABLE ACCESS BY INDEX ROWID| COLA_MARKETS_1
    4 DOMAIN INDEX     | COLA_SPATIAL_IDX_1
    5 TABLE ACCESS BY INDEX ROWID| COLA_MARKETS_2
    6 DOMAIN INDEX     | COLA_SPATIAL_IDX_2
    However, the above SDO_NN query will return 2 rows (one from each table),
    because it can only work on one table, it won't return the nearest neighbor
    from the combined view without some tweaks. For example, to return the
    top one, you may try:
    select * from (SELECT c.mkt_id, c.name FROM v1 c WHERE SDO_NN(c.shape, SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,3), SDO_ORDINATE_ARRAY(4,6, 8,8)) , 'sdo_num_res=1') = 'TRUE' order by sdo_geom.sdo_distance(c.shape, SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,3), SDO_ORDINATE_ARRAY(4,6, 8,8)), 0.0001)) where rownum < 2;
    Note that you can only pass literals or bind variables into the second input parameter
    of spatial operators (including SDO_NN), when a UNION ALL view is used. i.e. the following
    query won't work right now:
    SELECT c.* FROM v1 c, another_table b WHERE b.id =1 and SDO_NN(c.shape, b.shape, 'sdo_num_res=1')= 'TRUE';

Maybe you are looking for

  • My ipod touch says I need to update the software in order to access iTunes for apps, but iTunes says I have the most current version.  What do i do?

    I have an iPod touch.  When I try to download an app, it says I need to update the device's software to access the iTunes store.  But, when i connect to iTunes, it says I have the most current version.  I'm stuck.  My mother got this iPod as free-wit

  • BEx Maps

    Hello, at the moment we are using BEx Maps (Release SAP BW 3.5; Front-End Excel 2003). We are facing following problem: after saving the workbook with the embedded map for documentation as a .xls file and reopening it, we get a map with default value

  • Rendering Problems using PDK-URL (URL dynamically changes)

    Oracle 9i Application Server 1.0.2.2.1 Oracle Portal 3.0.9.8.0 PDK Services for Java version 3.0.9.0.5. PDK URL Services version 3.0.9.0.4. Oracle HTTP Server 1.3.19.0.0a The PDK-URL installed fine and the rendering examples work (www.google.com, etc

  • Power on password reset

    My laptop is asking for an administrator or power on password. I get the message Key:64439020 after 3 failed attempts. How can I reset/clear this password so I can turn on my laptop? This question was solved. View Solution.

  • Here is some interview qustions i have faced please help

    1) How can we take output returned by Stored Pocedure? 2) Diffarence b/w MVC1 and MVC2 ? 3) Why SinglethreadModel is deprecated? 4) while useing polymorphisam what's wrong with instanceof() method? 5) Servelt chaning follows which designpattern? 6) w