Simple spatial query with different SRID

Can anyone help me with just a real simple spatial query with different SRID.
Here is the error i get when i perform the query:
AND SDO_RELATE(A.geometrie_point, B.GEOMETRIE_POLYGONE, 'mask=anyinteract querytype=WINDOW') = 'TRUE'
ERROR at line 4:
ORA-00604: error occurred at recursive SQL level 1
ORA-13207: incorrect use of the [IN COMPATIBLE BOUNDS in SDO_RELATE] operator
ORA-06512: at "MDSYS.SDO_INDEX_METHOD", line 84
ORA-06512: at line 4

Hi,
I am using 8.1.7.2 and i have the lattest spatial patch.
From the start i had different SRID. The only thing i changed was the bounds of the coordinate system.
I reset my bounds of the coordinate system with SRID 8307 to -180,
180 in X (longitude), and -90,90 in Y (latitude) to see if the query window geometry
(geom2) will be transformed to the coordinate system of the layer geometries (geom1)
Her is the content of the user_sdo_geom_metadata :
GIS_PCP GEOMETRIE_POINT
SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', -5800000, 3600000, .00000005), SDO_DIM_ELEMENT('Y', 3516000, 6000000, .00000005))
82227
GIS_TEST GEOMETRIE_POLYGONE
SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', -180, 180, .00000005), SDO_DIM_ELEMENT('Y', -90, 90, .00000005))
8307
Here is my query :
select /*+ ordered */ A.no_point
from gis_pcp A, gis_test B
WHERE SDO_RELATE(A.geometrie_POINT, B.GEOMETRIE_POLYGONE, 'mask=anyinteract querytype=WINDOW') = 'TRUE';
Here is my result :
WHERE SDO_RELATE(A.geometrie_POINT, B.GEOMETRIE_POLYGONE, 'mask=anyinteract querytype=WINDOW') = 'TRUE'
ERROR at line 3:
ORA-00604: error occurred at recursive SQL level 1
ORA-13207: incorrect use of the [IN COMPATIBLE BOUNDS in SDO_RELATE] operator
ORA-06512: at "MDSYS.SDO_INDEX_METHOD", line 84
ORA-06512: at line 4
If i change the bounds of GIS_TEST to the exact bouns of GIS_PCP then i dont have the error message above and i have correct results. Do i have the adjust the bounds of every layer to fit the biggest bound?

Similar Messages

  • Import GeoRaster with different SRID

    Hi,
    I use the importFrom command to import TIF file into georaster table. I have raster files that's in two different SRID, 4267 NAD27 and 4269 NAD83. I have to use the georaster column in a sdo_relate query like the following.
    select a.georid
    from georaster_table a
    where sdo_relate(a.GEORASTER.spatialExtent, MDSYS.SDO_GEOMETRY(2001, 4269, MDSYS.SDO_POINT_TYPE(-121.5, 42.5, null), null, null), 'MASK=ANYINTERACT')='TRUE';
    My questions are:
    1) Can I store two different SRID data in the same georaster column? I understand that after I generate the spatial extent I have to create a row in the user_sdo_geom_metadata column and give it a SRID. It seems like to me I'll have to store raster objects with different SRID in seperate georaster columns, is that correct?
    2) Can I transform the TIF image into a specific SRID during, before or after the import so all my raster will have to the SRID?
    Thanks,
    -John

    John,
    For your first question. You can store all types of images and rasters in any SRID into the same GeoRaster table and in the same column.
    It is when you want to build a spatial Rtree index on that column, you need to make sure all GeoRaster spatialExtent geomtries (i.e., footprints) have the same SRID, which is a requirement from Rtree index instead of GeoRaster itself. you can call sdo_geor.generateSpatialextent on different georaster objects of any SRID and then sdo_cs.transform the extents into geometries in the same SRID, on which the spatial is going to be built.
    basically, if you wish you can use ONE single georaster table to store all or millions of images, which could cover the whole earth piece by piece. each of the images can have their own SRID (ground/model coordinate system), yet you can build a single spatial index (whole earth based such as WGS84) so that you can query images globally.
    for your second question, the answer is no. at this moment, GeoRaster doesn't have image reprojection capability in 10g. if you want all images to be physically in the same SRID (model CS), you have to do it using third party tools, such as those from PCI and Leica etc.
    hope this helps,
    thanks
    Jeffrey

  • Simple Spatial Query

    Can anyone help me with just a real simple spatial query. All I want to do is identify which police district a parcel falls in. I have two shapefiles police and parcel and I know I should do an relate but I just can't figure out to get the answer back. Can anyone help me.
    Matt

    Here is an example to try...
    select pd.district_name
    from parcels p,
    police_district pd
    where p.apn = 'XXXXXXXX'
    and mdsys.sdo_relate
    (p.shape,pa.shape,'querytype=window mask=anyinteract') = 'TRUE';
    Note that the table names have aliases (p and pd).
    I am just learning Oracle Spatial too but this example should work.
    Tom Elder
    City of Phoenix
    [email protected]

  • Simple Spatial Query caused ORA-03113: end-of-file on communication channel

    I try to run a simple spatial query to find the ID's which inside the specified circle
    select n.ID,n.FEATURE_ID
    from NC_MANGROVE n
    where sdo_relate(n.shape,
         mdsys.sdo_geometry(2003,null,null,
         mdsys.sdo_elem_info_array(1,1003,4),
         mdsys.sdo_ordinate_array(848948,834940,848908,834980,848908,834900)),
         'mask=ANYINTERACT querytype=WINDOW')='TRUE';
    but it end up of ORA-03113: end-of-file on communication channel
    Then I try another query, which I think do the similar thing
    select n.ID,n.FEATURE_ID
    from NC_MANGROVE n
    where sdo_within_distance(n.shape,
         mdsys.sdo_geometry(2001,null,mdsys.sdo_point_type(848908,834900,null),null,null),
         'distance=40')='TRUE';
    but same error occurs.
    Is it the SQL*net configure problem. I am using Oracle 8.1.7 for both client and server.
    Please help
    Tommy

    Does SDO_FILETER Queries work fine? If so there is already reported bug and patch for that on Metalink site. Get all the patches for 8.17 spatial and install those.

  • Use plan from stored_outlines from query with different syntax?

    Hello,
    I'd like to know is there any ability to use via stored_outlines plan from query with different syntax?
    Database version - 11.1.06
    If yes, maybe you'll take a look at steps (based on Metalink 726802.1), what I tried to do to make it work (with no success):
    alter session set create_stored_outlines=good;
    run good query
    create private outline good from SYS_OUTLINE_0... -< GOOD
    alter session set create_stored_outlines=bad;
    run bad query
    create private outline good from SYS_OUTLINE_0... -< BAD
    update ol$ set sql_text, textlen, signature, hash_value, hash_value2 from BAD to GOOD records
    leave ol$hintcount for GOOD untouched
    delete ol$ where ol_name='BAD';
    delete ol$hints where ol_name='BAD';
    delete ol$nodes where ol_name='BAD';
    execute dbms_outln_edit.refresh_private_outline('GOOD');
    alter session set sql_trace=true;
    alter session set use_private_outlines=true;
    run bad query
    examine trace file and find that it use execution plan different from both bad and good queries
    PS: Originally bad query is posted already Re: Poor performance while join of 2 comprehensive large views and small table
    PPS: Also I review thread CBO not picking correct indexes or doing Full Scans
    Thanks,
    Sergiy
    Edited by: kiberpress on Sep 30, 2009 6:59 AM

    A query with different syntax would result in a different hash value.
    Stored outlines work based on hash value.
    Your question is probably answered now.
    Sybrand Bakker
    Senior Oracle DBA

  • ORA-03113 in spatial query with xmlReader

    I run a spatial query with xmlReader. but it occurs a ORA-03113 exception. If i use the OracleDataReader,not through xml, the execution is ok. But i have to get the geometry data through xml. I have try to set the validate connection to True, but it seems useless.
    Can some one help me?Thx a lots.
    Here is my code:
         string id = "scott";
         string psw = "tiger";
         string source = "Oracle";
         string connectionstring = "User Id="+id+";password="+psw+";data source="+source+";validate connection=true";
         string sql ="select cname from L218 where sdo_relate(L218.GEOLOC,MDSYS.SDO_geometry(2003,NULL,NULL,MDSYS.SDO_elem_info_array(1,1003,3),MDSYS.SDO_ordinate_array(295596.60260187,2761786.9958782, 316370.598147679,2789383.2780762)),'mask=anyinteract')='TRUE'";
         try
              Oracle.DataAccess.Client.OracleConnection con = new OracleConnection(connectionstring);
              con.Open();
              Oracle.DataAccess.Client.OracleCommand cmd = con.CreateCommand();
              cmd.XmlCommandType = OracleXmlCommandType.Query;
              cmd.BindByName = true;
              cmd.CommandText =sql;
              XmlReader xmlReader = cmd.ExecuteXmlReader();
              XmlDocument xmlDocument = new XmlDocument();
              xmlDocument.PreserveWhitespace = false;
              xmlDocument.Load(xmlReader);
              Console.WriteLine(xmlDocument.OuterXml);
              con.Close();
         catch (OracleException e)
              Console.WriteLine(e);
    And it returns:
    Oracle.DataAccess.Client.OracleException ORA-03113: end-of-file on communication
    channel at Oracle.DataAccess.Client.OracleCommand.XmlHandleException(OracleE
    xception e)
    at Oracle.DataAccess.Client.OracleCommand.ExecuteXmlQuery(Boolean wantResult)
    at Oracle.DataAccess.Client.OracleCommand.ExecuteXmlReader()

    Hi Daniel
    I ran the validation and some of the geometries were invalid. I have now corrected these and all are OK. The db version is 817. However, I am still getting the same error. It appears to be dependant on what cordinates the query is searching:
    Errors
    SELECT 1
    FROM wpe_misc_site, WPE_PLAN_APPLICATION
    WHERE wpe_misc_site.ste_id > 0
    AND WPE_PLAN_APPLICATION.APL_ste_id(+) =
    wpe_misc_site.ste_id
    AND mdsys.sdo_relate(ste_geometry,
    MDSYS.SDO_GEOMETRY(2003, 81989, NULL,
    MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,3),
    MDSYS.SDO_ORDINATE_ARRAY(278792,187310,278876,187393)),
    'mask=anyinteract querytype=window') = 'TRUE';
    Substriute those coordinates for 278792,187308,278876,187393 and query works.
    Any ideas??
    Thanks
    Chris

  • Same query with different explain plans

    Hi All,
    I have one of the select query with different explain plans on two separate env, the query fetches the correct index on test env whereas on prod it's not fetching the same index.
    The structure, indices, no. of rows are similar in CRMINFO table with up-to-date statistics.
    Env Details :
    OS - Sun Solaris 5.10
    DB - 10.2.0.4
    Init param:
    Optimizer_mode = ALL_ROWS
    optimizer_dynamic_sampling integer 5
    optimizer_features_enable string 10.2.0.4
    optimizer_index_caching integer 90
    optimizer_index_cost_adj integer 30
    Query :*
    SELECT COUNT (*)
    FROM CRMINFO
    WHERE RETAILER = :1
    AND STATUS = 20
    AND EXC = :1
    AND SUBNO IS NULL
    Expain Plan (TST):
    SELECT STATEMENT ALL_ROWSCost: 916 Bytes: 19 Cardinality: 1                
    3 SORT AGGREGATE Bytes: 19 Cardinality: 1           
    2 TABLE ACCESS BY INDEX ROWID TABLE TST.CRMINFO Cost: 916 Bytes: 16,663 Cardinality: 877      
    1 INDEX RANGE SCAN INDEX TST.CRMINFO_X1 Cost: 42 Cardinality: 12,549
    Index (TST):
    CRMINFO_X1(EXC, RETAILER, STATUS)
    Explain Plan (PROD):
    SELECT STATEMENT ALL_ROWSCost: 1,832 Bytes: 19 Cardinality: 1                
    3 SORT AGGREGATE Bytes: 19 Cardinality: 1           
    2 TABLE ACCESS BY INDEX ROWID TABLE PROD.CRMINFO Cost: 1,832 Bytes: 2,052 Cardinality: 108      
    1 INDEX RANGE SCAN INDEX PROD.CRMINFO_X2 Cost: 117 Cardinality: 42,519
    Index (PROD):
    CRMINFO_X2 (RETAILER)
    How does Oracle calculates the cost and decides which index it should fetch ? Why it didn't choose the same index as of test env? How should i approach and which domains i need to dig-in to find the cause?
    I did try playing with the above mentioned init parameters but it didn't help at all.
    Thanks.
    Regards,
    ~Pointer

    Pointer wrote:
    Hmm, my worry is how do i force oracle to grap the proper index on prod i.e (CRMINFO_X1). I certainly believe it's a bad approach on adding a hint in the select statement and to force oralce to fetch that index.Why do you believe that, the index you mention is the "proper" index versus what Oracle is choosing? Can you prove with hinting that the "proper" index results in a faster and more efficient execution plan? If it does, then the next place I would look at is the statistics for the tables and columns of interest. From here you could try and estimate why Oracle thinks the other index is better. Another option is to run a 10053 (CBO) trace and see why Oracle thinks it is better.
    I would not support a hint in a production environment, except in the most extreme cases. Usually the CBO makes the right choice, but it only can if the statistics match the distribution of data.
    Refreshing the data may help me simulating the issue on TST but it wouldn't help me to understand why on prod it uses CRMINFO_X2 instead of CRMINFO_X1 which has all the three columns in the Where clause of the query.It would help because it's a test environment and you wouldn't have to do any queries directly on your production system to achieve the same results.
    >
    A bad thought here :( , if i create a new index by changing the column positioning say like ( RETAILER, STATUS , EXC) instead of (EXC, RETAILER, STATUS) will oracle fetch it ? or would it help in reducing the cost and cardinatlity of the select query.It's not that easy. There is a lot that goes into the cost calculation, some of that is known (through the great work by Jonathan Lewis and Richard Foote), and some of that is purely internal to Oracle. If you are more interested in the internals Cost-Based Oracle Fundamentals by Jonathan Lewis is a great book.
    HTH!

  • Query with 'different from' clause in Sqlite

    My question is very simple:
    How can I submit a query with a 'different from' clause into a table.
    In AIR, I would like to query :
    "select * from myTable where myField <> 'value' ";
    but it does'nt work !
    Nor
    "select * from myTable where myField != 'value' ";
    nor
    "select * from myTable where myField is not 'value' ";
    is it impossible to query with a 'different from' clause in Sqlite wih Adobe Air

    Hello,
    SQLite in AIR does support 'different from' and '<>' is the correct operator. Take the following emp table for example:
    id
    name
    age
    1
    A
    26
    2
    B
    30
    3
    C
    28
    If you want to query the records whose name isn't A. The following SQL is correct:
    select * from emp where name <> 'A'
    Thanks,
    Yang

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

  • Running Spatial Query as different user

    Has anyone else run into a problem with running a spatial query that works fine in the scheme that created the tables but when I run it after giving permissions to another user it returns no rows. Here is my example and sorry it is little complicated. I am running 9.2.0.7 are there specfic object or system privlidges i need to give the user that doesn't own those tables to run spaital functions?
    SELECT /*+ ORDERED ALL_ROWS */ COUNT(incident_n)
    FROM mpd_data.incidentsshp i
    WHERE sdo_relate(i.geom,(SELECT /*+ ORDERED ALL_ROWS */ sdo_geom.sdo_buffer(geom, m.diminfo, 2)
    FROM (SELECT /*+ ORDERED ALL_ROWS */ mdsys.sdo_aggr_union(mdsys.sdoaggrtype(union_geom, 0.5)) geom FROM (select mdsys.sdo_aggr_union(mdsys.SDOAGGRTYPE(d.geom,0.5)) union_geom
    from spatial.dime d WHERE d.rcd_nbr IN (select rcd_nbr
    from dime
    where ((lo_add_r >= 1500 and hi_add_r <= 1600) or
    (lo_add_l >= 1500 and hi_add_l <= 1600) or
    (1500 between lo_add_r and hi_add_r and
    1600 between lo_add_l and hi_add_l))
    and street = 'WARREN' and dir = 'N' and sttype = 'AV')))
    ,mdsys.user_sdo_geom_metadata m
    WHERE m.TABLE_NAME = 'DIME'), 'MASK = ANYINTERACT' ) = 'TRUE'
    and cdate between 20060101 and 20061231

    I have a separate schema for querying with and it works fine. I granted select on the needed tables and created synonyms (for convenience). Didn't have to do anything special for spatial indexes at all.
    I believe there is an issue doing spatial queries across a DB Link, so that should be avoided.
    --Peter                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Query with different parameter take different time to execute.

    Hi,
    I am a C/C++ programmer and newbie to database. I find weird case to my company database. oracle 10g.
    I have a query (below). When I set GENRE_ID value to 20, query execution time only take *5* seconds. But when I change to 10, it take *54* seconds! The same query but different values GENRE_ID (20 or 10) -- it also happen to other GENRE_ID values.
    on below query
    WHERE substr(GENRE_ID,0,2) = 10 and GENRE_ID != 10) take 54 seconds
    WHERE substr(GENRE_ID,0,2) = 20 and GENRE_ID != 20) take 5 seconds
    The explain plan give exact same result for both queries.
    I have follow Re: 3. How to  improve the performance of my query? / My query is running slow. for optimizer but the problem still there.
    And we have rebuilt all indexes.
    Anyone can help me? I need any advises for this problem.
    Note:
    Song table only have 570K records and Song_vod table 1100 records.
    Query:
    select *
    from(
    select rownum rowno, a.*
    from(
    select a.SONG_VOD_ID, a.SONG_ID, a.VOD_TITLE, a.ALBUM_ID, a.ARTIST_ID, a.VOD_ISSUE_DATE, a.VOD_ORDER_ISSUE_DATE, a.VOD_ADULT_YN, a.VOD_L_IMG_PATH, a.VOD_M_IMG_PATH, a.VOD_S_IMG_PATH, a.RECOMMEND_CNT, a.OPPOSE_CNT, get_song_name(a.SONG_ID) SONG_NAME, get_album_name(a.ALBUM_ID) ALBUM_NAME, get_artist_name(a.ARTIST_ID) ARTIST_NAME, VOD_ISSUE_DATE vodIssueDate
    from SONG_VOD a inner join SONG b on a.SONG_ID = b.SONG_ID
    where a.LC_STATUS_CD = 'CS0006'
    AND (b.GENRE_ID
    in (
    select GENRE_ID
    from MD_GENRE
    WHERE substr(GENRE_ID,0,2) = 10
    and GENRE_ID != 10)
    OR b.GENRE_ID
    in (
    select GENRE_ID
    from MD_GENRE
    WHERE substr(GENRE_ID,0,2) = '40'
    and GENRE_ID != '40'
    ) order by a.REG_DATE desc, a.SONG_VOD_ID desc
    ) a WHERE rownum <= 0 + 30
    Thank you,
    Regards
    -=Rika Chaniago=-

    907814 wrote:
    I am a C/C++ programmer and newbie to database. I find weird case to my company database. oracle 10g.
    I have a query (below). When I set GENRE_ID value to 20, query execution time only take *5* seconds. But when I change to 10, it take *54* seconds! The same query but different values GENRE_ID (20 or 10) -- it also happen to other GENRE_ID values.This is to be expected. Even an IDENTICAL query can (and often will) have DIFFERENT execution times.
    The typical reason is how fast the query process can get to the data block(s) containing the relevant row(s). Is that data block still on disk and require expensive and slow physical I/O to move it into the buffer cache for use? Is that data block already cached for much faster logical I/O access? If in memory, is there any contention in getting a latch for the chain the data block hangs off from (how hot is that block)? Etc.
    The run-time environment is not static. Thus execution times of queries (called cursors in Oracle) is not static. Execution times are expected to vary.
    Some basics. SQL code is source code. SQL code needs to be parsed and converted into a set of instructions that the server can execute. So it is similar to C/C++. SQL source code needs to be compiled. This executable code in Oracle is called a cursor.
    Like your code, the cursor can be executed with different input variables (bind variables). However, that code would have been compiled using certain assumptions about the data. And that executable code may work fine for some input data, and work not so okay for other input data. As the input parameter values are not not equal. E.g. there are a 1000 rows to process when employee type parameter is "employee" and only 10 rows when it is "manager". The code could have been compiled with the assumption that 10 rows would be the average for all input parameters - the Cost Based Optimiser needs to base its decision on the best execution path for that SQL source code on certain assumptions about the data. These may not always be correct. (usually due incorrect or stale stats about the data)
    Thus you also need to look at what the execution plan is (the URL for which has already been supplied).
    The Oracle® Database Performance Tuning Guide is at http://www.oracle.com/pls/db112/portal.all_books

  • Huge difference in Execution time in same Query with different Parameter

    Hi Experts,
    We are facing an unique problem once we are executing the query in HANA SQL prompt. This Query was generated from BObj and executing in HANA system. Once this query running with following condition, it is taking almost 7-00 minute to execute and returning around 924 rows.
    << WHERE
    Table__1."LOGSYS"  IN  ('RKGCLNT102')
    AND
    Table__1."CompanyCode"  IN  ('7240','7245')
    AND
    Table__1."Plant"  IN ……………… >
    However if we run the same query with some different plant, It is taking only 2 second. Please find the Query here.
    << WHERE
    Table__1."LOGSYS"  IN  ('RKGCLNT102')
    AND
    Table__1."CompanyCode"  IN  ('7245','7600')
    AND
    Table__1."Plant"  IN ……………… >
    This is really an unexpected behavior and we are not able to get the actual reason why it is behaving like this.
    Could anyone please help to analyze this issue to fine the root cause.
    Thanks in Advance.
    Regards
    Satrajit.

    Hi there
    Unfortunately you provided too few information to analyze the issue.
    Maybe the underlying tables have very skew data and the first select has to read a larger share of the base tables.
    Maybe the columns had been unloaded before and the first query had to load them into memory first.
    Is the runtime always bad with the one and always good with the other set of parameters?
    Have you checked the PlanViz for both versions? How do these differ?
    - Lars

  • Simulate query with different user

    Hello all,
    sometimes I receive calls from our user in BW that some query is not running/no authorization, but when i run the query it works, because I have rights to see everything.
    Is there any way to simulate how a query is running under a different user (which has restricted authorization). I want to check e.g  authorization but I do not want to copy existing user to a test user.
    I saw in the TA RSTRACE that I can enetr a different user, but how can I run a query with this user profile.
    Any help/ideas would be great. Thank you in advance.
    Best Regards,
    Stefan from Munich/Germany

    Hello Edwin,
    works perfect. Thank you.
    BR,
    Stefan

  • Query with different currency for different users

    Hi at all,
    just a crazy thing happened. I created a query. Every user gets the result with the currency EURO.
    Only one user here gets the country currency like US$, Francs etc.
    If he logs in on a different PC, he also gets EURO.
    So I think the problem is because of his PC.
    I already checked his user data in SAP and BW.
    And he really uses the same query with the same filters...
    Thanks for helping...
    Kind regards from totally confused Marielle

    Hi,
    Check the Front end Patch levels on both the machines. If they are different, then you can decide what you want to do, either upgrade it on other PCs or not use the one that has it.
    Cheers,
    Kedar

  • Oracle spatial query with php

    Hello, I have this problem,
    I use php for read data from oracle table,
    all works right, I have any problem whith varchar number type data, but when I must read geometry data like
    (type MDSYS.SDO_GEOMETRY)
    I can't display it on the web page.
    esemple of spatial query that I use:
    select GEOMETRY_1
    from table_a
    where
    ID = 970;
    If I use sql plus I have this result
    SDO_GEOMETRY(3001, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 0, 6000, 4, 1, 1), SDO_ORDINATE_ARRAY(1, -0, -
    0, 580094, 4998494, -1))
    but blank page when I use php sentence.
    I use PHP Version 4.4.0
    modules load are:
    extension=php_sdo.dll
    extension=php_oci8.dll
    But I don't know which other module I need and also which php function to use for read array of array. at the moment I use @OCIFetchInto.
    Someone can help me?
    My English is very bad please reply easy.
    Thanks for all!
    Angelo

    Thank you very much CJ.
    Now there isn't any problems: you and this link (Re: PHP and spatial data and Adamo Bozzetti helped me
    I have used SDO_UTIL.GETVERTICES
    my complete php script is:
    $conn = @OCILogon("xxxxxx", "xxxxx", "xxxxx") or die
    ( "Non riesco a connettermi al server $host ");
    $query = "select
    TABLE_A.tipo_via,
    TABLE_A.nome_via,
    c.codice_via,
    t.X,
    t.Y
    from TABLE B c, TABLE_A , TABLE(SDO_UTIL.GETVERTICES(c.geometry1)) t
    where c.codice_via = 830
    and c.codice_via = TABLE_A.id_via
    $istruzione = @OCIParse($conn, $query);
    @OCIExecute($istruzione);
    $nrows = @OCIFetchInto($istruzione, $results);
    $trovati = 0;
    while(@OCIFetchInto($istruzione, $results))
    $trovati++;
    ?>     
    <table border width="800" >
    <tr>     
    <td align="center" width="80" bgcolor ="#aaffee"><?echo trim($results[0]);?></td>
    <td align="center" width="150" bgcolor ="#eeffee"><?echo trim($results[1]);?></td>
    <td align="center" width="50" bgcolor ="#eeffee"><?echo trim($results[2]);?></td>
    <td align="center" width="50" bgcolor ="#eeffee"><?echo trim($results[3]);?></td>
    <td align="center" width="50" bgcolor ="#eeffee"><?echo trim($results[4]);?></td>
    </tr>
    </table>
    <?
    } //fine While
    @OCIFreeStatement($istruzione);
    @OCILogOff($conn);

Maybe you are looking for