Shorten my spatial query statement
HI ,
Can anybody help me shorten this query statement?
Thanks!
select tile.filename,
SDO_GEOM.SDO_AREA(
SDO_GEOM.SDO_INTERSECTION(tile.geometry,
MDSYS.SDO_GEOMETRY(2003, 8307, NULL,
MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 1),
MDSYS.SDO_ORDINATE_ARRAY(50,10, 70,10, 70,50, 50,50, 50,10)),
0.0005),0.0005) as area
from tile
WHERE tile.archiveId = 1
AND tile.dataType = 'Ortho'
AND
SDO_GEOM.SDO_AREA(
SDO_GEOM.SDO_INTERSECTION(tile.geometry,
MDSYS.SDO_GEOMETRY(2003, 8307, NULL,
MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 1),
MDSYS.SDO_ORDINATE_ARRAY(50,10, 70,10, 70,50, 50,50, 50,10)),
0.0005),0.0005) > 0
ORDER BY tileid;
Message was edited by:
eecow
You can define your test geometry once in an inline view, and use sdo_relates (ie, anyinteract and not touch) to ensure area>0. Something like this...
select a.filename, a.tileid
SDO_GEOM.SDO_AREA(
SDO_GEOM.SDO_INTERSECTION(a.geometry, b.g,0.0005),0.0005) as area
from tile a,
(select MDSYS.SDO_GEOMETRY(2003, 8307, NULL,
MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 1),
MDSYS.SDO_ORDINATE_ARRAY(50,10, 70,10, 70,50, 50,50, 50,10)) as g
from dual) b
where a.archiveid=1
and a.dataType = 'Ortho'
and sdo_anyinteract(a.geometry, b.g) = 'TRUE'
and sdo_touch(a.geometry, b.g) != 'TRUE'
order by a.tileid
I won't say it's necessarily optimized, but it's a little shorter.
Similar Messages
-
Spatial query in a distributed environment
We want to compare two spatial tables.
We have (at present identical) tables on two computers GEOSRV0 and NB25.
On both we have Oracle 10.1.0.2. GEOSRV0 has the WINDOWS 2000 operating system installed, on NB25 there is WINDOWS XP Professional.
The table is EZG:
GEOMETRY MDSYS.SDO_GEOMETRY
GEOMETRY_SK VARCHAR2(15)
EZG_NR NOT NULL NUMBER
FLAECHE FLOAT(126)
The primary key is EZG_NR.
There is a private database link for the user WLKREP on NB25 to user WLKREP on GEOSRV0.
The USER_SDO_GEOM_METADATA are the same on both machines (same SRID, same DIMINFO).
The following query â we check, if for each record on NB25 is a record on GEOSRV0 - works normally:
SQL> select ezg_nr from
2 ezg a where not exists
3 (select 1 from wlkrep.ezg@wlk where ezg_nr=a.ezg_nr);
no rows selected
This is correct.
We can read the geometry on the remote database:
SQL> select * from wlkrep.ezg@wlk where rownum=1;
GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
GEOMETRY_SK EZG_NR FLAECHE
SDO_GEOMETRY(3003, 1040001, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARRAY(182285.489, 405672.889, 0, 182248.701, 405644.889, 0, 182241.984, 405639.771, 0, 182171.753, 405538.805, 0, 182130.953, 405498.016, 0, 181971.1, 405274.91
6, 0, 182223.796, 405176.609, 0, 182292.701, 405204.37, 0, 182439.028, 405451.66
, 0, 182573.506, 405628.153, 0, 182643.64, 405726.59, 0, 182718.945, 405764.608,
0, 182780.371, 405805.57, 0, 182862.191, 405843.931, 0, 182966.69, 405933.13, 0
, 183131.065, 406064.852, 0, 183205.098, 406160.637, 0, 183231.535, 406220.959,
0, 183266.473, 406265.415, 0, 183308.669, 406303.524, 0, 183295.305, 406364.696,
0, 183204.283, 406331.35, 0, 183161.835, 406299.691, 0, 183134.554, 406243.403,
GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
GEOMETRY_SK EZG_NR FLAECHE
0, 183080.454, 406171.548, 0, 183027.376, 406123.698, 0, 182914.558, 406039.291
, 0, 182770.335, 405973.138, 0, 182593.691, 405886.413, 0, 182443.506, 405795.85
2, 0, 182343.293, 405713.991, 0, 182285.489, 405672.889, 0))
13 304906.065
Now we want to compare the geometry and get
SQL> select a.ezg_nr from
2 wlkrep.ezg@wlk b, ezg a where a.ezg_nr=b.ezg_nr and
3 sdo_equal(a.geometry,b.geometry) != 'TRUE';
select a.ezg_nr from
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Only comparing two elements gives the same result
SQL> select a.ezg_nr from
2 wlkrep.ezg@wlk b, ezg a where a.ezg_nr=640 and
3 b.ezg_nr = 640 and
4 sdo_equal(a.geometry,b.geometry) = 'TRUE';
select a.ezg_nr from
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Even if we query a non existing element
select count(*) from ezg where ezg_nr=99999;
COUNT(*)
0
SQL> select a.ezg_nr from
2 wlkrep.ezg@wlk b, ezg a where a.ezg_nr=99999 and
3 b.ezg_nr = 99999 and
4 sdo_equal(a.geometry,b.geometry) = 'TRUE';
select a.ezg_nr from
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Is this a bug or is a distributed spatial query not supported?
The following statement works:
SQL> select a.ezg_nr from
2 wlkrep.ezg@wlk a where not exists
3 (select 1 from ezg b where
4 b.ezg_nr=a.ezg_nr and
5 sdo_equal(b.geometry,a.geometry)='TRUE');
no rows selected
Regards
KarlActually, I have filed a TAR to Oracle on this. I also spoke to Steve Muench about it at OracleWorld, briefly. As of today, I'm trying to add to DataScroller.java to make it implement java.io.Serializable (with no luck...maybe someone can comment on what I'm doing wrong).
Here's what I have done so far.
Changed DataScroller.java (located in bc4jhtmlsrc.zip) to the following:
public class DataScroller implements java.io.Serializable
I added the following members per the docs on java.io.Serializable
private void writeObject(java.io.ObjectOutputStream out)
throws IOException
// really don't need to save state. Next call will recompute what's necessary
private void readObject(java.io.ObjectInputStream in)
throws IOException, ClassNotFoundException
// really don't need to load state. Next call will recompute what's necessary
I then used jar xvf to "unjar" datatags.jar, replaced DataScroller.class with my version and used
jar cv0Mf datatags.jar META-INF/* oracle/*
to recreate the datatags.jar. My file is not 100% the exact same as their file, but it looks to be right to me. I ended up doing it this way because the oracle\ord\* classes are not in the bc4jhtmlsrc.zip, only in the jar file and felt this was the "safest" way to include the correct contents of the file.
HOWEVER -- I'm sorry to say that I've then tried to run my app and get the same issue.
Thanks,
Jeff -
Spatial Query with multiple geometries from 2 tables
Hi,
I'm using Oracle 8.1.7. I am trying to do a spatial query on two tables with multiple geometries. There are two spatial tables. One made up of points and one made up of polygons. There are 829551 rows in the table of points and 1817795 rows in the table with polygons...
I want to find all polygons where one of this points is within it...
This query is pretty intensive querying two large spatial tables against each other and so I need to find the most efficient way of running this query. I've been running variations of my query for the last two week and every time it's bombed out with various errors after 12-24 hrs processing like out of memory, out of tablespace, out of processing, invalid index etc etc etc. I need to get this query run asap... Any tips would be gratefully appreciated..
For the session running the query I've allocated 16M sort area with
ALTER SESSION SET SORT_AREA_SIZE=16777216;
Below is the query I'm running... How can I improve this please? BTW PARCEL_OVERLAPS contains the points and TP$_PARCEL_AREAS the polygons.
SELECT lu.LNU_PARCEL_ID
FROM
seventy.PARCEL_OVERLAPS po,
imap_topol.TP$_PARCEL_AREAS pa,
TP$_PARCEL_CENTROID_AREA pca,
TDCR_LAND_UNIT lu
WHERE
SDO_FILTER(po.geometry, pa.area,
'querytype=WINDOW') = TRUE and
sdo_within_distance(po.geometry,pa.area,'distance=0')='TRUE' and
pa.delete_date is null and
Lu.LNU_LAND_UNIT_UNIQUE_NUM = pca.CENTROID_ID and
pa.AREA_ID = pca.AREA_ID and
pca.DELETE_DATE IS NULL and
pa.DELETE_DATE IS NULL;Albert,
Thanks for your reply and the tips you've given. The tp$_parcel_areas table will always be bigger so I've changed the order to sdo_within_distance(pa.area,po.geometry,'distance=0')='TRUE'. The requested counts for those queries are
12:26:29 [email protected]:SQL> select count(*)
13:46:22 2 from seventy.PARCEL_OVERLAPS;
COUNT(*)
612
13:48:12 [email protected]:SQL> select count(*)
13:48:17 2 from imap_topol.TP$_PARCEL_AREAS pa,
13:48:21 3 TP$_PARCEL_CENTROID_AREA pca
13:48:21 4 where pca.DELETE_DATE IS NULL
13:48:21 5 and pa.DELETE_DATE IS NULL
13:48:21 6 and pa.AREA_ID = pca.AREA_ID;
COUNT(*)
1310665
There was no reason for both filter and within_distance. I did try use the anyinteract but for some reason that does not return the desired results(I've added one id row as a test to make sure it returns desired results). Plus Oracle have recomended using the within distance for better performance..
so the explan plan for
14:38:37 [email protected]:SQL> EXPLAIN PLAN FOR
14:38:50 2 SELECT lu.LNU_PARCEL_ID
14:38:50 3 FROM
14:38:50 4 seventy.PARCEL_OVERLAPS po,
14:38:50 5 imap_topol.TP$_PARCEL_AREAS pa,
14:38:50 6 TP$_PARCEL_CENTROID_AREA pca,
14:38:50 7 TDCR_LAND_UNIT lu
14:38:50 8 WHERE
14:38:50 9 sdo_within_distance(pa.area,po.geometry,'distance=0')='TRUE' and
14:38:50 10 pa.delete_date is null and
14:38:50 11 Lu.LNU_LAND_UNIT_UNIQUE_NUM = pca.CENTROID_ID and
14:38:50 12 pa.AREA_ID = pca.AREA_ID and
14:38:50 13 pca.DELETE_DATE IS NULL and
14:38:50 14 pa.DELETE_DATE IS NULL;
is
Plan Table
| Operation | Name | Rows | Bytes| Cost | Pstart| Pstop |
| SELECT STATEMENT | | 4G|32920G| 547M| | |
| NESTED LOOPS | | 4G|32920G| 547M| | |
| MERGE JOIN | | 547M| 2029G| 230124 | | |
| SORT JOIN | | 1M| 36M| 85014 | | |
| MERGE JOIN | | 1M| 36M| 50019 | | |
| SORT JOIN | | 1M| 17M| 21650 | | |
| TABLE ACCESS FULL |TP$_PARCE | 1M| 17M| 485 | | |
| SORT JOIN | | 1M| 22M| 28369 | | |
| TABLE ACCESS FULL |TDCR_LAND | 1M| 22M| 2127 | | |
| SORT JOIN | | 42K| 160M| 145111 | | |
| TABLE ACCESS FULL |TP$_PARCE | 42K| 160M| 12697 | | |
| TABLE ACCESS FULL |PARCEL_OV | 817 | 3M| 1 | | |
14:43:14 [email protected]:SQL> explain plan for
14:43:23 2 SELECT pa.AREA_ID
14:43:23 3 FROM seventy.PARCEL_OVERLAPS po,
14:43:23 4 imap_topol.TP$_PARCEL_AREAS pa
14:43:23 5 WHERE SDO_RELATE(po.geometry, pa.area,'mask=ANTINTERACT querytype=WINDOW') = 'TRUE'
14:43:23 6 and pa.DELETE_DATE IS NULL;
Plan Table
| Operation | Name | Rows | Bytes| Cost | Pstart| Pstop |
| SELECT STATEMENT | | 6M| 50G| 10M| | |
| NESTED LOOPS | | 6M| 50G| 10M| | |
| TABLE ACCESS FULL |PARCEL_OV | 817 | 3M| 1 | | |
| TABLE ACCESS FULL |TP$_PARCE | 850K| 3G| 12697 | | |
14:45:03 [email protected]:SQL> explain plan for
14:45:04 2 SELECT pa.AREA_ID
14:45:05 3 FROM seventy.PARCEL_OVERLAPS po,
14:45:05 4 imap_topol.TP$_PARCEL_AREAS pa
14:45:05 5 WHERE SDO_RELATE(pa.area, po.geometry,'mask=ANTINTERACT querytype=WINDOW') = 'TRUE'
14:45:05 6 and pa.DELETE_DATE IS NULL;
Plan Table
| Operation | Name | Rows | Bytes| Cost | Pstart| Pstop |
| SELECT STATEMENT | | 6M| 50G| 863554 | | |
| NESTED LOOPS | | 6M| 50G| 863554 | | |
| TABLE ACCESS FULL |TP$_PARCE | 850K| 3G| 12697 | | |
| TABLE ACCESS FULL |PARCEL_OV | 817 | 3M| 1 | | |
-------------------------------------------------------------------------------- -
Poor performance with Oracle Spatial when spatial query invoked remotely
Is anyone aware of any problems with Oracle Spatial (10.2.0.4 with patches 6989483 and 7003151 on Red Hat Linux 4) which might explain why a spatial query (SDO_WITHIN_DISTANCE) would perform 20 times worse when it was invoked remotely from another computer (using SQLplus) vs. invoking the very same query from the database server itself (also using SQLplus)?
Does Oracle Spatial have any known problems with servers which use SAN disk storage? That is the primary difference between a server in which I see this poor performance and another server where the performance is fine.
Thank you in advance for any thoughts you might share.OK, that's clearer.
Are you sure it is the SQL inside the procedure that is causing the problem? To check, try extracting the SQL from inside the procedure and run it in SQLPLUS with
set autotrace on
set timing on
SELECT ....If the plans and performance are the same then it may be something inside the procedure itself.
Have you profiled the procedure? Here is an example of how to do it:
Prompt Firstly, create PL/SQL profiler table
@$ORACLE_HOME/rdbms/admin/proftab.sql
Prompt Secondly, use the profiler to gather stats on execution characteristics
DECLARE
l_run_num PLS_INTEGER := 1;
l_max_num PLS_INTEGER := 1;
v_geom mdsys.sdo_geometry := mdsys.sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,0,45,45,90,0,135,45,180,0,180,-45,45,-45,0,0));
BEGIN
dbms_output.put_line('Start Profiler Result = ' || DBMS_PROFILER.START_PROFILER(run_comment => 'PARALLEL PROFILE')); -- The comment name can be anything: here it is related to the Parallel procedure I am testing.
v_geom := Parallel(v_geom,10,0.05,1); -- Put your procedure call here
dbms_output.put_line('Stop Profiler Result = ' || DBMS_PROFILER.STOP_PROFILER );
END;
SHOW ERRORS
Prompt Finally, report activity
COLUMN runid FORMAT 99999
COLUMN run_comment FORMAT A40
SELECT runid || ',' || run_date || ',' || run_comment || ',' || run_total_time
FROM plsql_profiler_runs
ORDER BY runid;
COLUMN runid FORMAT 99999
COLUMN unit_number FORMAT 99999
COLUMN unit_type FORMAT A20
COLUMN unit_owner FORMAT A20
COLUMN text FORMAT A100
compute sum label 'Total_Time' of total_time on runid
break on runid skip 1
set linesize 200
SELECT u.runid || ',' ||
u.unit_name,
d.line#,
d.total_occur,
d.total_time,
text
FROM plsql_profiler_units u
JOIN plsql_profiler_data d ON u.runid = d.runid
AND
u.unit_number = d.unit_number
JOIN all_source als ON ( als.owner = 'CODESYS'
AND als.type = u.unit_type
AND als.name = u.unit_name
AND als.line = d.line# )
WHERE u.runid = (SELECT max(runid) FROM plsql_profiler_runs)
ORDER BY d.total_time desc;Run the profiler in both environments and see if you can see where the slowdown exists.
regards
Simon -
PL/SQL spatial query will not compile.
I have a PL/SQL spatial query that will not compile, but the equivalent SQLPlus query works fine. I.e. (convert decimal degrees to degrees,minutes,seconds)
Any thoughts much appreciated....
THIS WORKS in SQLPlus
select
decode(rownum,1,decode(sign(b.column_value),-1,'W','E'),2,decode(sign(b.column_v
alue),-1,'S','N'))| |
to_char(abs(trunc(b.column_value,0)),'999')
| |to_char(abs(trunc((b.column_value - trunc(b.column_value,0)) * 60,0)),'99')
| |to_char(abs(
(((b.column_value - trunc(b.column_value,0)) * 60) - trunc((b.column_value - tru
nc(b.column_value,0)) * 60,0)) * 60
),'99.99')
from route_location a, table(a.line.sdo_ordinates) b
where a.route_adms_id = 13820370
and record_seq_num = 26
and rownum < 3
BUT THIS DOES NOT
ADMS>create or replace procedure PKG_route_loc_latlong_ins
2 (iADMS_ID in INTEGER, iRSN in INTEGER,
3 vcLAT out VARCHAR2, vcLONG out VARCHAR2) as
4 cursor c1 is
5 select decode(rownum,1,decode(sign(b.column_value),-1,'W','E'),
6 2,decode(sign(b.column_value),-1,'S','N'))
7 | |to_char(abs(trunc(b.column_value,0)),'999')
8 | |to_char(abs(trunc((b.column_value - trunc(b.column_value,0)) * 60,0)),
'99')
9 | |to_char(abs(
10 (((b.column_value - trunc(b.column_value,0)) * 60) -
11 trunc((b.column_value - trunc(b.column_value,0)) * 60,0)) * 60
12 ),'99.99')
13 from route_location a, table(a.line.sdo_ordinates) b
14 where a.route_adms_id = iADMS_ID
15 and a.record_seq_num = iRSN
16 and rownum < 3;
17 BEGIN
18 open c1;
19 fetch c1 into vcLONG;
20 fetch c1 into vcLAT;
21
22 EXCEPTION
23 when others then
24 vcLAT := 'ERROR';
25 RAISE_APPLICATION_ERROR(-20002,
26 'XXXXXXXXXXXXXX ');
27
28 END pkg_route_loc_latlong_ins;
29 /
Warning: Procedure created with compilation errors.
ADMS>
ADMS>show errors
Errors for PROCEDURE PKG_ROUTE_LOC_LATLONG_INS:
LINE/COL ERROR
5/5 PL/SQL: SQL Statement ignored
5/12 PLS-00320: the declaration of the type of this expression is
incomplete or malformed
5/12 PLS-00320: the declaration of the type of this expression is
incomplete or malformed
13/34 PLS-00201: identifier 'A.LINE' must be declared
19/5 PL/SQL: SQL Statement ignored
20/5 PL/SQL: SQL Statement ignored
nulltry a
FOR UPDATE OF ID NOWAIT;where ID is the name of a column in the table. -
Memory Leak During Spatial Query
Platform:
Oracle 8.1.7 EE with Spatial
Windows NT 4.0
I'm seeing a memory leak that I have determined has something to do with spatial. Here is the PL/SQL code that generates the leak:
DECLARE
v_id NUMBER(16);
v_longitude NUMBER(15,10);
v_latitude NUMBER(15,10);
v_wirecenter_name VARCHAR2(11);
CURSOR c_Source IS
SELECT id, longitude, latitude
FROM prospects_geocode_info;
CURSOR c_WC IS
SELECT wc.wirecenter_name
FROM ion_info.ion_wirecenters wc
WHERE mdsys.sdo_relate(wc.geoloc,
mdsys.sdo_geometry(2001,
8265,
mdsys.sdo_point_type(v_longitude,
v_latitude,
NULL),
NULL,
NULL),
'mask=contains querytype=window') = 'TRUE';
BEGIN
open c_Source;
loop
fetch c_Source into v_id, v_longitude, v_latitude;
exit when c_Source%NOTFOUND;
if v_longitude is not NULL and v_latitude is not NULL THEN
open c_WC;
loop
fetch c_WC into v_wirecenter_name;
exit when c_WC%NOTFOUND;
end loop;
close c_WC;
end if;
end loop;
close c_Source;
END;
I'm attributing the link to spatial because if I change the c_WC cursor's SELECT statement to not use a spatial query, I get no leak. As near as I can tell I'm leaking a little bit of memory with each spatial query. I can watch the consumed memory jump in 64K blocks about every second or two on the machine I am running on.
I have tried pinning the code in memory, as well as pinning the spatial index and it's table in memory. None of this helps. I am continuing to experiment with this, but wanted to see if anyone had any ideas.
Thanks.
Matt.I have been able to reproduce the memory leak now using a very simple anonymous PL/SQL block. All it is doing is looping through a range of lon/lat and issuing a given spatial query. Here it is:
DECLARE
v_longitude NUMBER(15,10) := 0;
v_latitude NUMBER(15,10) := 0;
v_miprinx NUMBER;
v_lon_start NUMBER(15,10) := -150.0000000000;
v_lon_end NUMBER(15,10) := -30.0000000000;
v_lat_start NUMBER(15,10) := 20.0000000000;
v_lat_end NUMBER(15,10) := 70.0000000000;
CURSOR c_test IS
SELECT mi_prinx
FROM ion_info.ion_markets
WHERE mdsys.sdo_relate(geoloc,
mdsys.sdo_geometry(2001,
8265,
mdsys.sdo_point_type(v_longitude,
v_latitude,
NULL),
NULL,
NULL),
'mask=contains querytype=window') = 'TRUE';
BEGIN
FOR v_longitude IN v_lon_start..v_lon_end LOOP
FOR v_latitude IN v_lat_start .. v_lat_end LOOP
OPEN c_test;
LOOP
FETCH c_test
INTO v_miprinx;
EXIT WHEN c_test%NOTFOUND;
END LOOP;
CLOSE c_test;
END LOOP;
END LOOP;
END;
On my 8.1.7 database on NT 4.0 I get the same results on all three tables that have spatial indexes. I tried this on a different spatial table on 8.1.6 on NT 4.0 and saw no memory leak. It doesn't matter whether I execute the script using sqlplus or sqlplusw.
Matt. -
Performance issue with Spatial query
Need inputs to optimize a spatial query that takes 9 seconds to return 34410 rows. All tables have been analyzed. Plan shows indexes columns. Details below :
SELECT count(*) FROM (select ANT_DIR_GEOLOC , decode(D_UL_SQE_LOW,0,0,D_UL_SQE_LOW/D_UL_SQE_CHECK) as D_UL_SQE_BAD_SECTORS
from dae_admin.VIEW_D_UL_SQE_BAD_SECTOR G , SECTORS S Where G.SECTOR_ID = S.SECTOR_ID and WEEK_NUMBER=32 and
WEEK_NUMBER_YEAR=2007 and WEEKEND = 'N')
WHERE MDSYS.SDO_FILTER(ANT_DIR_GEOLOC, MDSYS.SDO_GEOMETRY(2003, 99900001,NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003,
3),MDSYS.SDO_ORDINATE_ARRAY(-1.06449263071068E7,3111428.11503326,-8140237.76425813,5605276.61542001)), 'querytype=WINDOW') ='TRUE'
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 146 | | 26699 (1)| 00:05:21 |
| 1 | SORT AGGREGATE | | 1 | 146 | | | |
|* 2 | HASH JOIN | | 1123 | 160K| | 26699 (1)| 00:05:21 |
| 3 | PARTITION RANGE ALL | | 1123 | 152K| | 603 (1)| 00:00:08 |
| 4 | TABLE ACCESS BY LOCAL INDEX ROWID | SECTORS | 1123 | 152K| | 603 (1)| 00:00:
|* 5 | DOMAIN INDEX | SECTORS_ANTDIR_SX | | | | | |
| 6 | VIEW | VIEW_D_UL_SQE_BAD_SECTOR | 20510 | 140K| | 26095 (1)| 00:05:14 |
| 7 | HASH GROUP BY | | 20510 | 901K| | 26095 (1)| 00:05:14 |
| 8 | VIEW | VIEW_D_UL_SQE_BAD_CARRIER | 984K| 42M| | 26095 (1)| 00:05:14 |
| 9 | HASH GROUP BY | | 984K| 73M| 180M| 26095 (1)| 00:05:14 |
| 10 | TABLE ACCESS BY LOCAL INDEX ROWID| FACT_DAILY_CHANNEL_STATS | 395K| 12M| | 603
| 11 | NESTED LOOPS | | 984K| 73M| | 8179 (1)| 00:01:39 |
| 12 | MERGE JOIN CARTESIAN | | 2 | 90 | | 4 (0)| 00:00:01 |
| 13 | TABLE ACCESS BY INDEX ROWID | NETWORK_PARAMETERS | 1 | 19 | | 2 (0)| 00:00
|* 14 | INDEX RANGE SCAN | NP_NAME_IDX | 1 | | | 1 (0)| 00:00:01 |
| 15 | BUFFER SORT | | 5 | 130 | | 2 (0)| 00:00:01 |
| 16 | TABLE ACCESS BY INDEX ROWID | DIM_TIME | 5 | 130 | | 2 (0)| 00:00:01 |
|* 17 | INDEX RANGE SCAN | DIM_TIME_WEEK_3_IX | 5 | | | 1 (0)| 00:00:01 |
| 18 | PARTITION RANGE ITERATOR | | 395K| | | 2139 (1)| 00:00:26 |
|* 19 | INDEX RANGE SCAN | FA_DCC_EVENT_DATE_NP_ID | 395K| | | 2139 (1)| 00:00:26 |
CREATE OR REPLACE VIEW VIEW_D_UL_SQE_BAD_SECTOR
(SECTOR_ID, WEEK_NUMBER_YEAR, WEEK_NUMBER, WEEKEND, D_UL_SQE_LOW,
D_UL_SQE_CHECK)
AS
SELECT sector_id,
week_number_year,
week_number,
weekend,
SUM(d_ul_sqe_low) d_ul_sqe_low,
SUM(d_ul_sqe_check) d_ul_sqe_check
FROM view_d_ul_sqe_bad_carrier
GROUP BY sector_id, week_number_year, week_number, weekend
view_d_ul_sqe_bad_carrier:
SELECT /*+ index(f) */
f.sector_id,
f.channel,
f.br_id,
t.week_number_year,
t.week_number,
t.weekend,
SUM(f.np_value_numerator) d_ul_sqe_low,
SUM(f.np_value_denominator) d_ul_sqe_check
FROM fact_daily_channel_stats f, network_parameters p, dim_time t
WHERE f.np_id = p.np_id
AND f.event_date = t.event_date
AND p.name = 'DL_UL_SQE_LOW_RATE'
GROUP BY f.sector_id, f.channel, f.br_id, t.week_number_year, t.week_number, t.weekend
fact_daily_channel_stats is a table that isPartitioned on event date.Ivan - Yes, all the columns in the filter are indexed.
Row Count:
==========
fact_daily_channel_stats - 101263303
network_parameters - 168
SECTORS - 105216
dim_time - 7306
Any tip/ clue on re-writing the query would be of great help.
Rich - Below is the response from our Spatial Team :
1. Projection:
We are working in Mercator projection. Since Oracle has out of the box Mercator with datum NAD 27 (SRID=49155), and we needed Mercator with NAD 83, we defined our own projection with SRID = 99900001, which you are seeing in our query. Projection is defined as:
insert into sdo_coord_ref_system
SELECT 99900001, a.coord_ref_sys_name, a.coord_ref_sys_kind,
a.coord_sys_id, a.datum_id, 10076,
2000023, a.projection_conv_id, a.cmpd_horiz_srid,
a.cmpd_vert_srid, a.information_source, a.data_source,
a.is_legacy, a.legacy_code, 'PROJCS["Mercator", GEOGCS [ "NAD 83", DATUM ["NAD 83", SPHEROID ["GRS 80", 6378137, 298.257222101]], PRIMEM [ "Greenwich", 0.000000 ], UNIT ["Decimal Degree", 0.01745329251994330]], PROJECTION ["Mercator"], UNIT ["Meter", 1.000000000000]]', a.legacy_cs_bounds, a.is_valid, a.supports_sdo_geometry
FROM mdsys.sdo_coord_ref_sys a where srid=49155;
2. Metadata for SECTORS table is:
INSERT INTO USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID)
VALUES('SECTORS', 'GEOLOC',SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', -20037566, 20037566, 1),
SDO_DIM_ELEMENT('Y', -71957574, 71957574, 1)),99900001);
which means tolerance is 1 meter.
3. Precision - I don't think we need to supply to MDSYS.SDO_FILTER coordinates with such great precision. Maybe rounding them (by dropping fractional part at all, 1 meter should be enough) would help. If not - then maybe we need to round coordinates we generate when converting from longitude/latitude to Mercator and store in SECTORS table. But on the other hand SECTORS table defines tolerance of 1 meter in metadata, and spatial index should use that tolerance. -
Bugy nearest neighbour spatial query?
Hi,
I have the following problem. The last query below returns the bad number of rows and I suspect some RDBMS bug behinde this, but am not really shure. Could some one please have a look?
-- Preparation steps:
-- Create 'Varos' Table
CREATE TABLE VAROS (
GMIPRIMARYKEY NUMBER (10) NOT NULL,
TNEV VARCHAR2 (50),
NEV VARCHAR2 (50),
GEOMETRY MDSYS.SDO_GEOMETRY,
PRIMARY KEY ( GMIPRIMARYKEY ));
-- Insert 5 records
-- 2 have no name (nev attribute contains 'nincs neve')
-- 3 have meaningful name
insert into varos values (615484,'Kisszentmarton','58131',MDSYS.SDO_GEOMETRY(2002,NULL,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),MDSYS.SDO_ORDINATE_ARRAY(18.04725,45.788384,18.04698,45.786578)));
insert into varos values (617351,'Czn','nincs neve',MDSYS.SDO_GEOMETRY(2002,NULL,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),MDSYS.SDO_ORDINATE_ARRAY(18.060483,45.785141,18.060615,45.784949,18.06079,45.783938,18.061508,45.782226,18.061641,45.781539,18.061686,45.780696,18.061677,45.780531)));
insert into varos values (617352,'Czn','nincs neve',MDSYS.SDO_GEOMETRY(2002,NULL,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),MDSYS.SDO_ORDINATE_ARRAY(18.061677,45.780531,18.061638,45.779749,18.061463,45.778458,18.061103,45.777196,18.060708,45.776133,18.060355,45.775182)));
insert into varos values (622732,'Vejti','Tancsics Mihaly utca',MDSYS.SDO_GEOMETRY(2002,NULL,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),MDSYS.SDO_ORDINATE_ARRAY(17.964469,45.809845,17.964149,45.809448,17.9641,45.809356,17.964009,45.809186,17.964004,45.808933,17.964007,45.808886,17.964169,45.808335,17.964781,45.807061,17.965233,45.806119,17.965492,45.805637,17.965682,45.805283,17.965802,45.805063,17.965932,45.804825,17.966221,45.804298)));
insert into varos values (629498,'Pisks','5821',MDSYS.SDO_GEOMETRY(2002,NULL,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),MDSYS.SDO_ORDINATE_ARRAY(17.912804,45.80585,17.913105,45.805645,17.922503,45.803835,17.935384,45.803584)));
-- Insert metadata record
insert into USER_SDO_GEOM_METADATA values('VAROS','GEOMETRY',MDSYS.SDO_DIM_ARRAY( MDSYS.SDO_DIM_ELEMENT('Lon',16,23,0.00000001),MDSYS.SDO_DIM_ELEMENT('Lat',45.5,48.8,0.00000001)),NULL);
-- Commit
commit;
-- Create spatial index
CREATE INDEX VAROS_INDEX ON VAROS(GEOMETRY) INDEXTYPE IS MDSYS.SPATIAL_INDEX PARAMETERS('SDO_LEVEL=10 SDO_NUMTILES=8');
-- Test steps:
-- Select records with not 'nincs neve'
select gmiprimarykey,tnev,nev
from varos
where nev <> 'nincs neve';
-- It fetches 3 records
-- 615484,Kisszentmarton,58131
-- 622732,Vejti,Tancsics Mihaly utca
-- 629498,Pisks,5821
-- Right.
-- Embed the above select statement as a subselect to a nearest-neighbour spatial query.
-- It is requested to return the 3 nearest records ('sdo_num_res=3').
select gmiprimarykey,tnev,nev
from ( select gmiprimarykey,tnev,nev,geometry
from varos
where nev <> 'nincs neve'
) y
where mdsys.SDO_NN(y.geometry,mdsys.sdo_geometry(2001,NULL,mdsys.sdo_point_type(18,45.5,0),NULL,NULL),'sdo_num_res=3')='TRUE';
-- It is expected to return 3 records (the same ones as above), but it returns only 1 single record
-- 615484,Kisszentmarton,58131
-- Wrong.
It seems that Oracle executes the neaest neighbour spatial query BEFORE evaluating the inline view.
Regards,
Tamas Szecsy
[email protected]Hi,
The nearest neighbor query has to use the spatial index, and there is no way to filter the results and
use the spatial index.
So, in Oracle9i the SDO_NN tuning parameter SDO_BATCH_SIZE was introduced - what this does is
keep streaming results from the SDO_NN query until some other condition is met.
Rewriting your query to use SDO_BATCH_SIZE:
select gmiprimarykey,tnev,nev
from varos y
where mdsys.SDO_NN(y.geometry,
mdsys.sdo_geometry(2001,NULL,mdsys.sdo_point_type(18,45.5,0),NULL,NULL),
'sdo_batch_size=5')='TRUE'
and nev <> 'nincs neve'
and rownum < 4;
Two things about SDO_BATCH_SIZE:
Cannot be used with SDO_NUM_RES
Requires an R-tree index
Also, you are using hybrid quadtree indexes. At this point in time, there are almost no situations where
Oracle recommends using hybrid quadtree indexes (this is true in all versions of Oracle Spatial).
As of Oracle9i, the recommendation is to use R-tree indexes (which work as well or better than
quadtree indexes most of the time). Certainly if you require the incremental nearest neighbor functionality
described above then you need to use an R-tree index.
If you must use a quadtree index, then you will still have to use sdo_num_res, but you should try to set the
number large enough so that any filtering leaves enough in the result set. -
Spatial query w/ logical operators in a subquery on Linux using Oracle 1
Hello...
I'm being given XML that I need to parse and create SQL from it. Below my signature is the SQL that I generate (its a simple example) and can be more elaborate due to the logical operators (AND and OR) given in the XML.
The problem that we're seeing is performance-based: when one of the logical operator queries is Spatial-based, like below. Running it in JDBC, the query never returns.
The spatial query just by itself returns ~300 rows (takes approximately 0.2 seconds). The "PERCENTAGE" query by itself returns about ~40000 rows (takes approximately ~.8 seconds).
If we run the query below with 2 non-spatial subqueries, the result returns and performance is very acceptable (~ 0.9 seconds)-- the result set is about 80000 rows.
Thanks,
Jim
=========================
SELECT
COLUMN_WE_WANT , RESULTS
FROM
TABLE_A
WHERE
COLUMN_WE_WANT IN
SELECT
COLUMN_WE_WANT
FROM
TABLE_A
WHERE
SDO_OVERLAPBDYINTERSECT(TABLE_A.MY_SPATIAL_COLUMN,
SDO_GEOMETRY(2003,
4326,
null,
SDO_elem_info_array( 1 , 3 , 1 ),
SDO_ORDINATE_ARRAY( lng_1,lat_1 , lng_2,lat_2 , lng_3,lat_3 , lng_4,lat_4 , lng_1,lat_1 )
) = 'TRUE'
OR
COLUMN_WE_WANT IN
SELECT
COLUMN_WE_WANT
FROM
TABLE_B
WHERE
SOME_PERCENTAGE_RATE_COLUMN < 90
)Its difficult to comment without seeing the execution plan. You should trace this query to get a better idea of exactly what's happening.
Depending on the complexity of the logical operators, I would look at doing this using set operations. So for an OR you might have...
SELECT COLUMN_WE_WANT, RESULTS
FROM TABLE_A
WHERE COLUMN_WE_WANT IN (
SELECT COLUMN_WE_WANT
FROM TABLE_A
WHERE SDO_OVERLAPBDYINTERSECT(TABLE_A.MY_SPATIAL_COLUMN,SDO_GEOMETRY(2003,4326,
NULL, SDO_elem_info_array( 1 , 3 , 1 ),
SDO_ORDINATE_ARRAY( lng_1,lat_1 , lng_2,lat_2 , lng_3,lat_3 , lng_4,lat_4 , lng_1,lat_1 ) )) = 'TRUE'
UNION
SELECT COLUMN_WE_WANT
FROM TABLE_B
WHERE SOME_PERCENTAGE_RATE_COLUMN < 90)For an AND, you would use INTERSECT.
Edited by: Reggie to remove the extra INTERSECT -
Spatial query w/ logical operators in a subquery on Linux using Oracle 10g
Hello...
I'm being given XML that I need to parse and create SQL from it. Below my signature is the SQL that I generate (its a simple example) and can be more elaborate due to the logical operators (AND and OR) given in the XML.
The problem that we're seeing is performance-based: when one of the logical operator queries is Spatial-based, like below. Running it in JDBC, the query never returns.
The spatial query just by itself returns ~300 rows (takes approximately 0.2 seconds). The "PERCENTAGE" query by itself returns about ~40000 rows (takes approximately ~.8 seconds).
If we run the query below with 2 non-spatial subqueries, the result returns and performance is very acceptable (~ 0.9 seconds)-- the result set is about 80000 rows.
Thanks,
Jim
=========================
SELECT
COLUMN_WE_WANT , RESULTS
FROM
TABLE_A
WHERE
COLUMN_WE_WANT IN
SELECT
COLUMN_WE_WANT
FROM
TABLE_A
WHERE
SDO_OVERLAPBDYINTERSECT(TABLE_A.MY_SPATIAL_COLUMN,
SDO_GEOMETRY(2003,
4326,
null,
SDO_elem_info_array( 1 , 3 , 1 ),
SDO_ORDINATE_ARRAY( lng_1,lat_1 , lng_2,lat_2 , lng_3,lat_3 , lng_4,lat_4 , lng_1,lat_1 ) )
) = 'TRUE'
OR
COLUMN_WE_WANT IN
SELECT
COLUMN_WE_WANT
FROM
TABLE_B
WHERE
SOME_PERCENTAGE_RATE_COLUMN < 90
)There is a spatial forum. You will likely have a far better experience there.
-
How to insert a sql query statement in the table
I have a stored procedure which has different insert,update statements on different tables. I am writing a trigger on these tables such that when the record is updated or inserted in these tables a trigger should fire and should write the old value,new value and the query (insert or update) that caused the trigger to fire in the seperate table. Is there any way to find out the exact query statement that fired the trigger?
Rather than inventing your own demi-donkeyed solution I recommend you consider using Oracle's Fine-Grained Auditing which does precisely this.
Cheers, APC -
How to get the SQL Query statement of a Search Form ?
Hi all,
We have a requirement to send the query result of an ADF Search Form into report application (Crystal rpt).
Crystal can accept data source as query statement. SO I think of getting the exact query statement "generated" by the ADF Search form and send it to crystal.
Is this possible ?
Thank you very much,
xtantoTry the various get methods of the viewObject such as getQuery:
http://www.oracle.com/webapps/online-help/jdeveloper/10.1.2/state/content/navId.4/navSetId._/vtAnchor.getQuery%28%29/vtTopicFile.bc4jjavadoc%7Crt%7Coracle%7Cjbo%7CViewObject%7Ehtml/ -
How to get these Attribute class in Query Statement ?
Hi All,
I have 2 SCCM primary site, the first one is a migrated site from SCCM 2007 to SCCM 2012 SP1 & then upgraded to SCCM 2012 R2, the second one is a newly created SCCM 2012 R2 site.
I was trying to create a collection membership rule using the query statement on the second site & i found there are attribute classes which were missing on this site.
Under query rule /edit query rule in the criteria tab i am trying to define a new criteria with Criteria type : Simple value & then i click the select under "Where" for chossing the attribute class & a value called "Winlogon64"
don't exists there. There are other classes which are missing too.
then i go to my first site & i can see the classes there, collection query rule are also defined using the attribute classes.
Now my questions are :-
1. Does these settings gets migrated from SCCM 2007 to SCCM 2012 on the first site?
2. How can we get this in SCCM 2012 R2 on the second site?
Experts please help.
Thanks,
Pranay.It sounds a lot like you where using an extension on your hardware inventory. Changes to your hardware inventory are not migrated, so you would need to recreate that change in the hardware inventory.
My Blog: http://www.petervanderwoude.nl/
Follow me on twitter: pvanderwoude -
SSRS - SQL Server Spatial Query
Hi, I was hoping someone could help me.
I'm creating an SSRS report with Map and importing points via SQL Server Spatial query. I have a db table with 8,000 points bu the import only ever brings in the first 2,000 queried (no matter what the filter is). Is there a limitation in SSRS that can be
changed via a configuration setting?
Many thanks in advance for any help on this,
Steve.Really appreciate you coming back so quick Olaf.
No its a straightforward query (select AccountNum, Name, Address, Longitude, Lattitude, UrbanArea, County, MI_STYLE, MI_PRINX, SP_GEOMETRY from <table>)
Just to give the whole picture. I had 8,000 points in MapInfo version 10. I imported them to SQL Server 2012 via MapInfo Easy Loader.
The SQL Server spatial points import to SSRS and the Bing overlay map works great (so they import to correct space) but its only a subset of the points that import. I can pick any subset using the WHERE clause but I cannot get all 8,000 points.
I was hoping there was a configuration setting somewhere in SSRS that was causing the problem. -
Export with embedded spatial query
I am trying to use the exp utility to export spatial data. I am using the "query" parameter to specify a spatial query based on another spatial layer.
I have two layers. Admin1 has lots of administrative boundaries. PE has three polygons in it over different sections of my data set. I want to get the data extracted from admin1 that exists in these areas to an export file(along with all the triggers and other related database objects). I was hoping this approach would work
I am getting errors saying that the identifier is too long.
Here is the par file:
file=1.exp
log=1.log
tables=(admin1, pe)
query="""WHERE mdsys.SDO_RELATE(GEOM1,pe.GEOM, 'MASK=INSIDE QUERYTYPE=WINDOW')='TRUE' OR SDO_RELATE(GEOM2,pe.GEOM, 'MASK=INSIDE QUERYTYPE=WINDOW')='TRUE'"""
I get:
Export: Release 10.2.0.1.0 - Production on Wed May 10 11:56:14 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Produc
tion
With the Partitioning, OLAP and Data Mining options
Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
About to export specified tables via Conventional Path ...
. . exporting table ADMIN1
EXP-00056: ORACLE error 972 encountered
ORA-00972: identifier is too long
. . exporting table PE
EXP-00056: ORACLE error 972 encountered
ORA-00972: identifier is too long
Export terminated successfully with warnings.
Is this even possible? Can you use the exp query parameter to perform a spatial operation? Did this work? I am accustom to seeing record counts next to the exported tables, and they are not present in the output from exp. The export file is not empty. It exported all the features, not the subset I had requested.
How can I structure the query differently so that I get the export file with just the lines that fall within the polygons?
Thanks,
JohnI am trying to use the exp utility to export spatial data. I am using the "query" parameter to specify a spatial query based on another spatial layer.
I have two layers. Admin1 has lots of administrative boundaries. PE has three polygons in it over different sections of my data set. I want to get the data extracted from admin1 that exists in these areas to an export file(along with all the triggers and other related database objects). I was hoping this approach would work
I am getting errors saying that the identifier is too long.
Here is the par file:
file=1.exp
log=1.log
tables=(admin1, pe)
query="""WHERE mdsys.SDO_RELATE(GEOM1,pe.GEOM, 'MASK=INSIDE QUERYTYPE=WINDOW')='TRUE' OR SDO_RELATE(GEOM2,pe.GEOM, 'MASK=INSIDE QUERYTYPE=WINDOW')='TRUE'"""
I get:
Export: Release 10.2.0.1.0 - Production on Wed May 10 11:56:14 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Produc
tion
With the Partitioning, OLAP and Data Mining options
Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
About to export specified tables via Conventional Path ...
. . exporting table ADMIN1
EXP-00056: ORACLE error 972 encountered
ORA-00972: identifier is too long
. . exporting table PE
EXP-00056: ORACLE error 972 encountered
ORA-00972: identifier is too long
Export terminated successfully with warnings.
Is this even possible? Can you use the exp query parameter to perform a spatial operation? Did this work? I am accustom to seeing record counts next to the exported tables, and they are not present in the output from exp. The export file is not empty. It exported all the features, not the subset I had requested.
How can I structure the query differently so that I get the export file with just the lines that fall within the polygons?
Thanks,
John
Maybe you are looking for
-
Can i have more than one apple id?
can i have more than one apple id listed to a single email acount?
-
Hi, I have a latest Macbook Pro Retina. I connect its hdmi port to a DisportPort of HP Compaq LA2205wg external monitor, but no signal at all. Could anybody help me
-
BPC Security: User should only see status of packages started by himself
Dear Experts, we have the users run packages to perform their planning process and we also trained them to check their package status so they know when to go on within the process. Until now we have not had a very intelligent security management sinc
-
Adding transitions in iDVD?
I'm making my first dvd and am having a slight problem with it. I have a slideshow from iPhoto that is in a .mov filetype with dimensions: 720x540. I want to add a title and fade in/fade out transitions but I don't want to diminish the quality of the
-
What is the difference bwt other spl. indicator and normal spl. indiactor
Hi What is the difference bwt other spl. indicator(OBXT) and normal spl. indiactor(OBYR)? As per my knowldege other spl ind. which is used for not to update books and normal spl. ind. will updated the books? it is right. if that is right than in the