Performance of insert with spatial index

I'm writing a test that inserts (using OCI) 10,000 2D point geometries (gtype=2001) into a table with a single SDO_GEOMETRY column. I wrote the code doing the insert before setting up the index on the spatial column, thus I was aware of the insert speed (almost instantaneous) without a spatial index (with layer_gtype=POINT), and noticed immediately the performance drop with the index (> 10 seconds).
Here's the raw timing data of 3 runs in each 3 configuration (the clock ticks every 14 or 15 or 16 ms, thus the zero when it completes before the next tick):
                                   truncate execute commit
no spatial index                     0.016   0.171   0.016
no spatial index                     0.031   0.172   0.000
no spatial index                     0.031   0.204   0.000
index (1000 default for batch size)  0.141  10.937   1.547
index (1000 default for batch size)  0.094  11.125   1.531
index (1000 default for batch size)  0.094  10.937   1.610
index SDO_DML_BATCH_SIZE=10000       0.203  11.234   0.359
index SDO_DML_BATCH_SIZE=10000       0.094  10.828   0.344
index SDO_DML_BATCH_SIZE=10000       0.078  10.844   0.359As you can see, I played with SDO_DML_BATCH_SIZE to change the default of 1,000 to 10,000, which does improve the commit speed a bit from 1.5s to 0.35s (pretty good when you only look at these numbers...), but the shocking part of the almost 11s the inserts are now taking, compared to 0.2s without an index: that's a 50x drop in peformance!!!
I've looked at my table in SQL Developer, and it has no triggers associated, although there has to be something to mark the index as dirty so that it updates itself on commit.
So where is coming the huge overhead during the insert???
(by insert I mean the time OCIStmtExecute takes to run the array-bind of 10,000 points. It's exactly the same code with or without an index).
Can anyone explain the 50x insert performance drop?
Any suggestion on how to improve the performance of this scenario?
To provide another data point, creating the index itself on a populated table (with the same 10,000 points) takes less than 1 second, which is consistent with the commit speeds I'm seeing, and thus puzzles me all the more regarding this 10s insert overhead...
SQL> set timing on
SQL> select count(*) from within_point_distance_tab;
  COUNT(*)
     10000
Elapsed: 00:00:00.01
SQL> CREATE INDEX with6CDF1526$point$idx
  2            ON within_point_distance_tab(point)
  3    INDEXTYPE IS MDSYS.SPATIAL_INDEX
  4    PARAMETERS ('layer_gtype=POINT');
Index created.
Elapsed: 00:00:00.96
SQL> drop index WITH6CDF1526$POINT$IDX force;
Index dropped.
Elapsed: 00:00:00.57
SQL> CREATE INDEX with6CDF1526$point$idx
  2            ON within_point_distance_tab(point)
  3    INDEXTYPE IS MDSYS.SPATIAL_INDEX
  4    PARAMETERS ('layer_gtype=POINT SDO_DML_BATCH_SIZE=10000');
Index created.
Elapsed: 00:00:00.98
SQL>

Thanks for your input. We are likely to use partioning down the line, but what you are describing (partition exchange) is currently beyond my abilities in plain SQL, and how this could be accomplished from an OCI client application without affecting other users and keep the transaction boundaries sounds far from trivial. (i.e. can it made transparent to the client application, and does it require privileges the client does have???). I'll have to investigate this further though, and this technique sounds like one accessible to a DBA only, not from a plain client app with non-privileged credentials.
The thing that I fail to understand though, despite your explanation, is why the slow down is not entirely on the commit. After all, documentation for the SDO_DML_BATCH_SIZE parameter of the Spatial index implies that the index is updated on commit only, where new rows are fed 1,000 or 10,000 at a time to the indexing engine, and I do see time being spent during commit, but it's the geometry insert that slow down the most, and that to me looks quite strange.
It's so much slower that it's as if each geometry was indexed one at a time, when I'm doing a single insert with an array bind (i.e. equivalent to a bulk operation in PL/SQL), and if so much time is spend during the insert, then why is any time spent during the commit. In my opinion it's one or the other, but not both. What am I missing? --DD                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Performance problem at bulk insert with spatial index

    Hi,
    I have a table with SDO_GEOMETRY.
    Insert without spatial index is very fast, but with active spatial index it's very slow.
    So for the first big import of data, I can drop the index, import the data and again create the index. Thats 10 times faster!
    But for an already very big table that is no option.
    The 10g1-Users Guide (1) says at 4.1.3 that the spatial index should be set to 'deferred', the data should be inserted and than the index should be synchronized again. That sounds very good, but I can't find this at the 11g1-Users Guide.
    I tried it (11g1), but the performance is even worse than with active index!
    What could be my mistake? Any hints?
    Thank you,
    Bjoern Weitzig
    create table sggeoptcollection (pt SDO_GEOMETRY);
    CREATE INDEX myIdx ON sggeoptcollection (pt) INDEXTYPE IS MDSYS.SPATIAL_INDEX PARAMETERS('sdo_indx_dims=2, layer_gtype=point, sdo_rtr_pctfree=50');
    ALTER INDEX myIdx PARAMETERS ('index_status=deferred');
    Big import with batch'ed PreparedStatements
    ALTER INDEX myIdx PARAMETERS ('index_status=synchronize sdo_batch_size=500');
    1) http://download.oracle.com/docs/html/B10826_01/sdo_index_query.htm#g1010227

    Hi,
    I have a table with SDO_GEOMETRY.
    Insert without spatial index is very fast, but with active spatial index it's very slow.
    So for the first big import of data, I can drop the index, import the data and again create the index. Thats 10 times faster!
    But for an already very big table that is no option.
    The 10g1-Users Guide (1) says at 4.1.3 that the spatial index should be set to 'deferred', the data should be inserted and than the index should be synchronized again. That sounds very good, but I can't find this at the 11g1-Users Guide.
    I tried it (11g1), but the performance is even worse than with active index!
    What could be my mistake? Any hints?
    Thank you,
    Bjoern Weitzig
    create table sggeoptcollection (pt SDO_GEOMETRY);
    CREATE INDEX myIdx ON sggeoptcollection (pt) INDEXTYPE IS MDSYS.SPATIAL_INDEX PARAMETERS('sdo_indx_dims=2, layer_gtype=point, sdo_rtr_pctfree=50');
    ALTER INDEX myIdx PARAMETERS ('index_status=deferred');
    Big import with batch'ed PreparedStatements
    ALTER INDEX myIdx PARAMETERS ('index_status=synchronize sdo_batch_size=500');
    1) http://download.oracle.com/docs/html/B10826_01/sdo_index_query.htm#g1010227

  • Performance issue when inserting into spatial indexed table with JDBC

    We have a table named 'feature' which has a "sdo_geometry" column, and we created spatial index on that column,
    CREATE TABLE feature ( id number, desc varchar, oshape sdo_gemotry)
    CREATE INDEX feature_sp_idx ON feature(oshape) INDEXTYPE IS MDSYS.SPATIAL_INDEX;
    Then we executed the following SQL to insert about 800 records into that table(We tried this by using DB visualizer and
    our Java application, both of them were using JDBC driver to connect to the oracle 11gR2 database) .
    insert into feature(id,desc,oshape) values (1001,xxx,xxxxx);
    insert into feature (id,desc,oshape) values (1002,xxx,xxxxx);
    insert into feature (id,desc,oshape) values (1800,xxx,xxxxx);
    We encoutered the same problem as this topic
    Performance of insert with spatial index
    It takes nearly 1 secs for inserting one record,compare to 50 records inserted per sec without spatial index,
    which is 50x drop in peformance when doing insertion with spatial index.
    However, when we copy and paste those insertion scripts into Oracle Client(same test and same table with spatial index), we got a totally different performance result:
    more than 50 records inserted in 1 secs, just as fast as the insertion without building spatial index.
    Is it because Oracle Client is not using JDBC? Perhaps JDBC was got something wrong when updating those spatial indexed tables.
    Edited by: 860605 on 19/09/2011 18:57
    Edited by: 860605 on 19/09/2011 18:58
    Edited by: 860605 on 19/09/2011 19:00

    Normally JDBC use auto-commit. So each insert can causes a commit.
    I don't know about Oracle Client. In sqlplus, insert is just a insert,
    and you execute "commit" to explicitly commit your changes.
    So maybe this is the reason.

  • How to optimize massive insert on a table with spatial index ?

    Hello,
    I need to implement a load process for saving up to 20 000 points per minutes in Oracle 10G R2.
    These points represents car locations tracked by GPS and I need to store at least all position from the past 12 hours.
    My problem is that the spatial index is very costly during insert (For the moment I do only insertion).
    My several tries for the insertion by :
    - Java and PreparedStatement.executeBatch
    - Java and generation a SQLLoader file
    - Java and insertion on view with a trigger "instead of"
    give me the same results... (not so good)
    For the moment, I work on : DROP INDEX, INSERT, CREATE INDEX phases.
    But is there a way to only DISABLE INDEX and REBUILD INDEX only for inserted rows ?
    I used the APPEND option for insertion :
    INSERT /*+ APPEND */ INTO MY_TABLE (ID, LOCATION) VALUES (?, MDSYS.SDO_GEOMETRY(2001,NULL,MDSYS.SDO_POINT_TYPE(?, ?, NULL), NULL, NULL))
    My spatial index is created with the following options :
    'sdo_indx_dims=2,layer_gtype=point'
    Is there a way to optimize these heavy load ???
    What about the PARALLEL option and how does it work ? (Not so clear for me regarding the documentation... I am not a DBA)
    Thanks in advanced

    It is possible to insert + commit 20000 points in 16 seconds.
    select * from v$version;
    BANNER                                                                         
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod               
    PL/SQL Release 10.2.0.1.0 - Production                                         
    CORE     10.2.0.1.0     Production                                                     
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production                        
    NLSRTL Version 10.2.0.1.0 - Production                                         
    drop table testpoints;
    create table testpoints
    ( point mdsys.sdo_geometry);
    delete user_sdo_geom_metadata
    where table_name = 'TESTPOINTS'
    and   column_name = 'POINT';
    insert into user_sdo_geom_metadata values
    ('TESTPOINTS'
    ,'POINT'
    ,sdo_dim_array(sdo_dim_element('X',0,1000,0.01),sdo_dim_element('Y',0,1000,0.01))
    ,null)
    create index testpoints_i on testpoints (point)
    indextype is mdsys.spatial_index parameters ('sdo_indx_dims=2,layer_gtype=point');
    insert /*+ append */ into testpoints
    select (sdo_geometry(2001,null,sdo_point_type(1+ rownum / 20, 1 + rownum / 50, null),null,null))
    from all_objects where rownum < 20001;
    Duration: 00:00:10.68 seconds
    commit;
    Duration: 00:00:04.96 seconds
    select count(*) from testpoints;
      COUNT(*)                                                                     
         20000                                                                      The insert of 20 000 rows takes 11 seconds, the commit takes 5 seconds.
    In this example there is no data traffic between the Oracle database and a client but you have 60 -16 = 44 seconds to upload your points into a temporary table. After uploading in a temporary table you can do:
    insert /*+ append */ into testpoints
    select (sdo_geometry(2001,null,sdo_point_type(x,y, null),null,null))
    from temp_table;
    commit;Your insert ..... values is slow, do some bulk processing.
    I think it can be done, my XP computer that runs my database isn't state of the art.

  • Insert using Spatial Index fails when called from PHP

    I have a stored procedure that inserts into a table with a spatial index on one of its fields.
    When I run the procedure from SQL Server Management Studio it runs just fine.
    When I run it from PHP, it returns the error: "INSERT failed because the following SET options have incorrect settings: 'CONCAT_NULL_YIELDS_NULL, ANSI_WARNINGS, ANSI_PADDING'. Verify that SET options are correct for use with indexed views and/or indexes
    on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations"
    From within Management Studio, I have tried many different combinations of settings, until I wound up with the list I have in the procedure below.
    Within Managment Studio the error changes based on the options I have set, but PHP always replies with: 'CONCAT_NULL_YIELDS_NULL, ANSI_WARNINGS, ANSI_PADDING'
    I have configured PHP to use the same SQL user as management studio, and I have tried both mssql_query and mssql_execute with bound parameters.
    The spatial index is on the field post.location If I remove the spatial index it works, but I need the spatial index.
    CREATE PROCEDURE insert_post ( @subject AS VARCHAR(250), @body AS VARCHAR(2000), @latitude AS FLOAT, @longitude AS FLOAT ) AS BEGIN
    SET NOCOUNT ON
    SET ANSI_WARNINGS ON
    SET ANSI_PADDING ON
    SET CONCAT_NULL_YIELDS_NULL ON
    SET NUMERIC_ROUNDABORT OFF
    DECLARE @location AS geography = geography::Point(@latitude, @longitude, 4326)
    INSERT INTO post
        subject,
        body,
        location
    ) VALUES (
        @subject,
        @body,
        @location
    END

    Hi Charles
    Your issue looks like it have two basic sources: (1) The connection string properties, (2) The table structure and the data which you try to insert.
    (1) The connection string properties can be specified in various ways.
    You can set most of them during the connection, depending on the provider which you are using. We did not get from you any information about the PHP code, so we have no information regarding this part.
    The connection properties can be changed after the connection was made, which is basically what you have try to do. But we don't know what properties
    are differents (since you .. the PHP code..) but you can check those properties dynamically, insert them to a table and then compare. To check all the properties you can use this post:
    http://ariely.info/Blog/tabid/83/EntryId/153/SQL-Server-Get-Connection-Properties.aspx
    (2) We need to understand your
    table structure and compare it to yours query. Please post your DDL+DML (queries to create the table and to insert some sample data), and the full SP code
    as it is now.
    [Personal Site]  [Blog]  [Facebook]

  • Partial insert with secondary index

    I'd like to use partial inserts (DB_DBT_PARTIAL).
    However, I also need secondary indexes. Now when I insert partial data, the secondary index function is immediately called, but still I do not have enough data to calculate the secondary key. I tried to supply some app_data do the DBT, but it does not reach the secondary index function.
    Is there any way I can use partial inserts together with secondary indexes?

    When writing a partial record to the primary database, here's what we do:
    1. Look up the existing record via get()
    2. Using the existing record and the partial DBT, construct the new record
    3. Pass that newly constructed record to the secondary key generation function
    You don't need to do anything special, your callback will receive the full record, even though you passed us a partial DBT. If that's not the case, there's a bug in BDB and we'd need to see your code.
    app_data is a private field, you should not try to use it or expect it to work predictably. In this situation, we're passing a brand new DBT to the callback function, not the DBT you gave us. That's why app_data is empty.
    Thanks,
    Bogdan Coman

  • Insert with unique index slow in 10g

    Hi,
    We are experiencing very slow response when a dup key is inserted into a table with unique index under 10g. the scenario can be demonstrated in sqlplus with 'timing on':
    CREATE TABLE yyy (Col_1 VARCHAR2(5 BYTE) NOT NULL, Col_2 VARCHAR2(10 BYTE) NOT NULL);
    CREATE UNIQUE INDEX yyy on yyy(col_1,col_2);
    insert into yyy values ('1','1');
    insert into yyy values ('1','1');
    the 2nd insert results in "unique constraint" error, but under our 10g the response time is consistently in the range of 00:00:00.64. The 1st insert only took 00:00:00.01. BTW, if no index or non-unique index then you can insert many times and all of them return fast. Under our 9.2 DB the response time is always under 00:00:00.01 with no-, unique- and non-unique index.
    We are on AIX 5.3 & 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production.
    Has anybody seen this scenario?
    Thanks,
    David

    It seems that in 10g Oracle simply is doing something more.
    I used your example and run following script on 9.2 and 10.2. Hardware is the same i.e. these are two instances on the same box.
    begin
      for i in 1..10000 loop
        begin
          insert into yyy values ('1','1');
        exception when others then null;
        end;
      end loop;
    end;
    /on 10g it took 01:15.08 and on 9i 00:47.06
    Running trace showed that in 9i there was difference in plan of following recursive sql:
    9i plan:
    select c.name, u.name
    from
    con$ c, cdef$ cd, user$ u  where c.con# = cd.con# and cd.enabled = :1 and
      c.owner# = u.user#
    call     count       cpu    elapsed       disk      query    current        rows
    Parse    10000      0.43       0.43          0          0          0           0
    Execute  10000      1.09       1.07          0          0          0           0
    Fetch    10000      0.23       0.19          0      20000          0           0
    total    30000      1.76       1.70          0      20000          0           0
    Misses in library cache during parse: 1
    Optimizer mode: CHOOSE
    Parsing user id: SYS   (recursive depth: 2)
    Rows     Row Source Operation
          0  NESTED LOOPS 
          0   NESTED LOOPS 
          0    TABLE ACCESS BY INDEX ROWID CDEF$
          0     INDEX RANGE SCAN I_CDEF4 (object id 53)
          0    TABLE ACCESS BY INDEX ROWID CON$
          0     INDEX UNIQUE SCAN I_CON2 (object id 49)
          0   TABLE ACCESS CLUSTER USER$
          0    INDEX UNIQUE SCAN I_USER# (object id 11)10g plan
    select c.name, u.name
    from
    con$ c, cdef$ cd, user$ u  where c.con# = cd.con# and cd.enabled = :1 and
      c.owner# = u.user#
    call     count       cpu    elapsed       disk      query    current        rows
    Parse    10000      0.21       0.20          0          0          0           0
    Execute  10000      1.20       1.31          0          0          0           0
    Fetch    10000      2.37       2.59          0      20000          0           0
    total    30000      3.79       4.11          0      20000          0           0
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: CHOOSE
    Parsing user id: SYS   (recursive depth: 2)
    Rows     Row Source Operation
          0  HASH JOIN  (cr=2 pr=0 pw=0 time=301 us)
          0   NESTED LOOPS  (cr=2 pr=0 pw=0 time=44 us)
          0    TABLE ACCESS BY INDEX ROWID CDEF$ (cr=2 pr=0 pw=0 time=40 us)
          0     INDEX RANGE SCAN I_CDEF4 (cr=2 pr=0 pw=0 time=27 us)(object id 53)
          0    TABLE ACCESS BY INDEX ROWID CON$ (cr=0 pr=0 pw=0 time=0 us)
          0     INDEX UNIQUE SCAN I_CON2 (cr=0 pr=0 pw=0 time=0 us)(object id 49)
          0   TABLE ACCESS FULL USER$ (cr=0 pr=0 pw=0 time=0 us)So in 10g it had hash join instead of nested loop join at least for this particular select. Probably time to gather stats on sys tables?
    The difference in time wasn't so big though 4.11 vs 1.70 so it doesn't explain all the time taken.
    But you can probably check whether you haven't more difference.
    Also you can download Thomas Kyte runstats_pkg and run it on both environments to compare whether some stats or latches haven't very big difference.
    Gints Plivna
    http://www.gplivna.eu

  • Error dialog when open index dialog on tables with spatial index

    Hi all,
    When I want to open in the preferences of a table with a spatial index the index dialog, then there appears the following message:
    "Index <myIndex> column GEOMETRY, datatype SDO_GEOMETRY is not a valid column type for use in a text index".
    I can only click the ok button, but I am not able to modify any of my set index.
    Does anyone else have the same problem?
    regards markus
    Version:
    Java: 1.6.0.16
    Oracle IDE: 2.1.1.64.39
    OS: Linux, Ubuntu 9.10
    Edited by: markusin on Mar 3, 2010 12:32 AM

    I have the same problem on SQLDev 2.1.1 for Windows. I hadn't this problem in 1.5.
    I must use a normal sql script to create spatial index.
    Vittorio

  • Materialized view issue with spatial index and UNION all.

    Hi guys,
    I'm trying to build the following materialized view:
    create materialized VIEW MV_ElectricalStuffs
      refresh fast
      AS
      SELECT jb.ROWID,
        jb.FID,
        JB.NAME_NUMBER
      FROM EL_BUS_BAR jb
      UNION ALL
      SELECT INC.ROWID,
        INC.FID,
        NULL,
        INC.NAME_NUMBER
      FROM EL_INTERNAL_CELL INC;
    I have this error showing up:
    ORA-12015: cannot create a fast refresh materialized view from a complex query
    This is because the table EL_INTERNAL_CELL has a SDO_GEOMETRY column that has a spatial index, whose ddl is
    CREATE INDEX EL_INTERNAL_CELL_S ON EL_INTERNAL_CELL (GEOM) INDEXTYPE IS MDSYS.SPATIAL_INDEX
    PARAMETERS('SDO_INDX_DIMS=2 TABLESPACE=USERS LAYER_GTYPE=COLLECTION');
    When I remove the spatial index from EL_INTERNAL_CELL column GEOM, Oracle is very happy and creates the view.
    Is there a mean however to keep the spatial index in the materialized view?

    I've managed to drop the spatial index prior to create the materialized view and it is ok. After the materialized view creation, I've recreated the spatial index on the table and all ran smooth. Hope nothing will go bad in the future because of this trick on spatial index..

  • How can we differentiate normal indexes with spatial indexes

    how to knwo schema spatial indexes
    any queriy pls provide me
    thanks

    rp0428 wrote:
    Thanks for the link. My parents always said I was 'Spatial'. Now I know that is a good thing.(Spatial? Or just Spaced Out?)
    There are a few ways to tell, deending on what you are looking at.
    1) Spatial Indexes are implementd in regular tables, prefixed by MDRT$ (MultiDimensional R-Tree)
    2) They are DOMAIN indexes, and that is reflected by the INDEX_TYPE in ALL_INDEXES

  • Problems with spatial indexing

    Hi,folks,
    Thanks, first.
    When I try to build a function_based R-tree index on a table, I get the following error message.
    Is anyone has idea what I should look into to fix this problem.
    Thank you.
    ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-13203: failed to read USER_SDO_GEOM_METADATA table
    ORA-13203: failed to read USER_SDO_GEOM_METADATA table
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_9I", line 7
    ORA-06512: at line 1

    Hi,
    Thanks Dan.
    My step is:
    I have three relational tables: node, edge, polyline.
    They have relationship as following:
    each edge is bounded by two nodes,
    each polyline is bounded by two nodes and alos composed of a set of edges.
    I made functions to get geometry on each table as following:
    get_node_geometry(ndid)
    get_edge_geometry(edid)
    get_polyline_geometry(pdid)
    mdsys.sdo_geometry as return type.
    Note that coordinates are saved only with node table.
    But edge and polyline can construct themselvel by functions above.
    After that, I made r-tree index on node, and edge. But it can not work on polyline table for some reasons. I got the error messages from the last postage.
    I just note that in my polyline table there are some self-close polylines, which have the same start and terminate node.
    Is that possible problem causing the OCIIndexCreate error?
    I debugged my code in jdeveloper, by tracing that, there seems no error to return polyline geometry object using get_polyline_geometry function.
    Do you have any clue?
    many thanks,

  • Poor performance of inserts w/ table indexed

    I have a java application that inserts approximately 2M records
    into 2 different tables in an Oracle 8i database (NT). If I
    place indexes on the tables, the whole process is drastically
    slower than when I don't have indexes (18 hrs vs. 1.5 hrs). I
    can understand some factor of slowdown, but I would have
    expected the DB to utilize the CPU more intensively. My server
    is a dual-p3/450 w/ 256M and U2W scsi discs in a SW RAID
    config. Average CPU utilization of oracle is 2-3%. Is there
    anyway to keep my indexes but have the data go into the db in a
    reasonable amount of time? Thanks.
    null

    Brian Lelek (guest) wrote:
    : I suggest that the process that does the inserts should do the
    : following:
    : 1. Drop the indexes
    : 2. Insert the rows
    : 3. Recreate the indexes
    : This may be faster than leaving the indexes during the inserts.
    : Brian
    : Brian Krahmer (guest) wrote:
    : : I have a java application that inserts approximately 2M
    : records
    : : into 2 different tables in an Oracle 8i database (NT). If I
    : : place indexes on the tables, the whole process is
    drastically
    : : slower than when I don't have indexes (18 hrs vs. 1.5 hrs).
    I
    : : can understand some factor of slowdown, but I would have
    : : expected the DB to utilize the CPU more intensively. My
    : server
    : : is a dual-p3/450 w/ 256M and U2W scsi discs in a SW RAID
    : : config. Average CPU utilization of oracle is 2-3%. Is
    there
    : : anyway to keep my indexes but have the data go into the db
    in
    : a
    : : reasonable amount of time? Thanks.
    Need to see ur script which insert the records.
    I guss , records are inserted one by one. Is it
    possible to insert in bunch. Second analyse the
    indexes are really required ? rebuilding of indexes
    will be faster than recreating it .
    null

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

  • CBO and spatial index

    For a table with 2 million rows, with just ID=123 in the where clause it takes some msecs to return one row, but with a sdo_relate in the where clause, CBO checks both indexes, and if the spatial filter window is big, then can take 30 minutes to return.
    This is the query:
    SELECT g1.geometry
    FROM STAGE1.PARCEL_GEOMETRIES g1
    WHERE g1.id=123 and
    (mdsys.sdo_relate (g1.geometry,:FilterGeometry, 'mask=ANYINTERACT querytype=window') = 'TRUE');
    This is the plan:
    SELECT STATEMENT ALL_ROWSCost: 2 Bytes: 32 Cardinality: 1                               
         8 TABLE ACCESS BY INDEX ROWID TABLE STAGE1.PARCEL_GEOMETRIES Cost: 2 Bytes: 32 Cardinality: 1                          
              7 BITMAP CONVERSION TO ROWIDS                     
                   6 BITMAP AND                
                        2 BITMAP CONVERSION FROM ROWIDS           
                             1 INDEX RANGE SCAN INDEX STAGE1.PGM_PK Cost: 1 Cardinality: 1      
                        5 BITMAP CONVERSION FROM ROWIDS           
                             4 SORT ORDER BY      
                                  3 DOMAIN INDEX INDEX (DOMAIN) STAGE1.PGM_GMIDX Cost: 1 Cardinality: 1
    When I put in a no_index hint to ignore spatial index, it returns right away:
    SELECT /*+ NO_INDEX(g1 pgm_gmidx)*/ g1.geometry
    FROM STAGE1.PARCEL_GEOMETRIES g1
    WHERE g1.id=123 and
    (mdsys.sdo_relate (g1.geometry,:FilterGeometry, 'mask=ANYINTERACT querytype=window') = 'TRUE');
    Plan
    SELECT STATEMENT ALL_ROWSCost: 1 Bytes: 32 Cardinality: 1           
         2 TABLE ACCESS BY INDEX ROWID TABLE STAGE1.PARCEL_GEOMETRIES Cost: 1 Bytes: 32 Cardinality: 1      
              1 INDEX RANGE SCAN INDEX STAGE1.PGM_PK Cost: 1 Cardinality: 1
    My question is, why CBO chose to use spatial index while it knows only one row returned from id=123? With spatial index it can return 500,000 rows from sdo_relate. I do need the spatial index because for other cases it's being used. Is there anything I can do? Is this "work as design"?
    Thanks!!

    Thanks Bryan.
    My database is 10.2.0.4. Although the problem is not the query is doing full table scan here. It's using spatial index. But problem is the attribute query, which in this case is "id=123", has cardinality 1, or 0, if the spatial query can use the 1 geometry return from "id=123", then it works very fast. But because spatial index is being used, so it takes a long time to run if the filter window is big.
    In my test case I disabled the spatial index then it worked very fast. What I meant was, I couldn't use hint to disable spatial index to allow this scenario work fast because in other cases I do need the spatial index.
    Thanks again!
    Sharon

  • Problems creating an spatial index with srid=4326

    Hi!
    I would like to know if somebody can help me with the following problem: We are using the 10.2.0.1 version and we need that our SRID value is 4326. We do not have problems with 8307 or another value. However, when we tried to use srid = 4326, appears the following error message:
    Error on line 17 CREATE INDEX SIDX_D3M_SDO_GEOMETRY ON DAT_3DM_MODEL (DM3_SDO_GEOMETRY) INDEXTYPE ORA-29855: an error in the execution of routine ODCIINDEXCREATE has taken place ORA-13249: internal error in Spatial index: [mdidxrbd] ORA-13249: Error initializing geodetic transform ORA-06512: in “MDSYS.SDO_INDEX_METHOD_10I”, line 10
    The PL/SQL that we used is the following one:
    DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME = “DAT_3DM_MODEL”
    COMMIT
    INSERT INTO USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) VALUES('DAT_3DM_MODEL', 'DM3_SDO_GEOMETRY', MDSYS.SDO_DIM_ARRAY ( MDSYS.SDO_DIM_ELEMENT ('LONGITUDE', -180, 180, 0,05), -- MDSYS.SDO_DIM_ELEMENT ('LATITUDE', -90, 90, 0.05) ), 4326 )
    CREATE INDEX SIDX_D3M_SDO_GEOMETRY ON DAT_3DM_MODEL (DM3_SDO_GEOMETRY) INDEXTYPE IS MDSYS.SPATIAL_INDEX
    Thanks in advance,
    Susana.

    I cannot reproduce the error, in my environment. However:
    Your insert statement into USER_SDO_GEOM_METADATA appears to have included some typos. They might have happened, when transcribing. Please make sure you use the following:
    INSERT INTO USER_SDO_GEOM_METADATA (
    TABLE_NAME,
    COLUMN_NAME,
    DIMINFO,
    SRID)
    VALUES(
    'DAT_3DM_MODEL',
    'DM3_SDO_GEOMETRY',
    MDSYS.SDO_DIM_ARRAY (
    MDSYS.SDO_DIM_ELEMENT ('LONGITUDE', -180, 180, 10),
    MDSYS.SDO_DIM_ELEMENT ('LATITUDE', -90, 90, 10)),
    4326);
    However, the actual culprit is most certainly different. As I suspected, it might be related to the "decimal comma": In Germany, for instance, a decimal comma is used, instead of a decimal point. You have used a decimal comma in your original INSERT, as well (0,05 instead of 0.05).
    Please try the following:
    SQL> select wktext from cs_srs where srid = 4326;
    WKTEXT
    GEOGCS [ "WGS 84", DATUM ["World Geodetic System 1984 (EPSG ID 6326)", SPHEROID
    ["WGS 84 (EPSG ID 7030)", 6378137, 298.257223563]], PRIMEM [ "Greenwich", 0.0000
    00 ], UNIT ["Decimal Degree", 0.01745329251994328]]
    On your system, you will likely find a decimal comma, where my output has a decimal point. This is bug 5097326, which has been fixed, and backported to 10.2.0.3 and 10.2.0.4.

Maybe you are looking for