Cartesian queries
Can someone explain me, why result of this query:
select * from sys.v_$sql
where hash_value in
(select hash_value from sys.v_$sql_plan
where options = 'CARTESIAN' and operation LIKE '%JOIN%' )
order by hash_value; is that statement:
select count(1) from all_objects where object_name = :1;My point to run this query is find all cartesian join statements.
This is the "Downloads" forum - you will get a better/faster response in the PL/SQL forum (PL/SQL
HTH
Srini
Similar Messages
-
Grus help needed in finding the queries with Cartesian joins
Hi
I have a reporting tool in which users are allowed to put the joins on the views and add some sub queries that produces a Cartesian product. Is there any tool or way that I can stop the execution of those query before it is being executed for example
Step 1 ) user creates a query
step2 ) user submits it
step 3) by any tool or any check if Cartesian join is found the query execution is stopped and notify the user that the query is not good if no problem executes the query.
I really need help in step 3. I am on 9i release2.
Any help or suggestions will be highly appreciated.I Agree with Gasparotto, you should limit the resource consume.
You must understand that cartesian join, isn´t always a BAD guy, sometimes you need it.
If your developers are in trouble with handle the join , think about NATURAL JOIN, may be it helps you
Regards
Helio Dias -
Cartesian Product from in-line queries
I have the following query:
SELECT AUDIT_MONTH, AUDITS, DEFECTS
FROM
select distinct(to_char(AUDIT_DATE,'MM/YY')) as AUDIT_MONTH
from v_safety_audit_records
select count(distinct(AUDIT_ID)) AUDITS
from v_safety_audit_records
group by to_char(AUDIT_DATE,'MM/YY')
select count(KEY_ID) DEFECTS
from v_safety_audit_records
where SUBAREA_ID NOT LIKE '_98'
and SUBAREA_ID NOT LIKE '_99'
group by to_char(AUDIT_DATE,'MM/YY')
but it keeps giving me a cartesian product. Is there a way to re-write this so that I only get the month, the number of audits, and number of defects on a line rather than number of months x number of months worth of lines? I can't seem to get the join conditions worked out... I can re-write this all using views, but as it is for a single report, I'd rather not bother with more views if I can avoid it.
Thanks in advance.The problem is that the query doesn't return a single row and isn't meant to. I tried:
SELECT
select distinct(to_char(AUDIT_DATE,'MM/YY'))
from v_safety_audit_records
group by to_char(AUDIT_DATE,'MM/YY')
) AUDIT_MONTH,
select count(distinct(AUDIT_ID))
from v_safety_audit_records
group by to_char(AUDIT_DATE,'MM/YY')
) AUDITS,
select count(KEY_ID)
from v_safety_audit_records
where SUBAREA_ID NOT LIKE '_98'
and SUBAREA_ID NOT LIKE '_99'
group by to_char(AUDIT_DATE,'MM/YY')
) DEFECTS
FROM DUAL;
and got "ORA-01427: single-row subquery returns more than one row". It would be a good idea if I only needed it for one month, however. -
Report Developer Control Of Applying Hints to Analytics Queries
There are numerous ways to apply hints to the queries generated by Analytics:
- Table level
- Join level
- Evaluate calculation
Each has its advantages and drawbacks.
- Table level: applies the hint to every query that references the table.
- Join level: applies the hint whenever the join is used in the query.
- Evaluate: allows the report developer to include a hint, but can't control where Analytics decides to apply the hint.
I propose another method for the report developer to apply hints, when needed, that uses join level hints. All the report developer
does is add the hint column to the Answer or add a filter based on the hint column to the Answer to apply the hint.
Setup
NOTE: I suggest you do consistency checks along the way, especially before starting work in the next Layer, to be sure that all setup errors are resolved early.
1) Start by defining a Logical SQL table in the Physical Layer using the following SQL: Select 1 Hint from dual
2) Alias this table for each hint to be defined for report developer usage. As an example, alias the hint table, creating
No Star and Parallel alias tables.
3) Join each alias to the physical layer fact tables, using a complex join, where the hint could be applied. In the Join definition screen, put the hint in the HINT field and enter 1=1 for
in the Expression section. Yes, we are creating a cartesian join between the hint and the other joining table. As the hint table always returns one and only one row, there
is no effect on the rows returned by the query. For No Star, you
put NO_STAR_TRANSFORMATION in the Hint field. For Parallel, you put PARALLEL(<physical table name>, default, default), where the physical table name
is the name of the actual database table, not the name of the alias table (Analytics will put the alias in the place of the database table name
when it generates the SQL). Additionally, for hints that have no parameters, you only need to join it
to the Fact tables in a query and not necessarily the dimensions. If you include fields from multiple fact tables, the hint will be applied
for each fact table. So, you may see the hint multiple times in the SQL (something like SELECT /*+ NO_STAR_TRANSFORMATION NO_STAR_TRANSFORMATION */ t00001.col1...)
4) Add the hint alias tables to the BMM Layer.
5) Rename the Hint field in each of the BMM hint tables to identify the hint being applied. For No Star, change the column name from Hint to No Star Hint. For Parallel,
change the column name from Hint to Parallel Hint.
6) Set the hint column as a key.
7) Join the BMM hint tables to the appropriate fact tables, using a complex join.
8) Define each hint table as a dimension.
9) Set the Logical Level in the Content tab in each of the sources of the joined tables to use the Detail of the hint dimension.
10) Create a folder in the Presentation Layer called Hints
11) Place each BMM hint field into the Presentation Layer Hints folder.
To apply a hint to your Answer, either add the Hint field to your Answer or create a filter where the Hint field is equal to/is in 1 (the number one). Check that the SQL generated
contains the hint, in Answers, go into Administration, Session Manager, and view the log for the user (the user log level will need to have been set to 7 to see the SQL generated).
Use of hints in more complex setups can be done by performing a setup of the hints that is parallel to the fact table setup. As an example, if you specify fragmentation content and a where
clause in your BMM for your fact tables, you would setup parallel physical layer hint tables and joins, BMM objects and joins, fragmentation content, and where clauses based on the
hint tables (only hint tables are referenced in the where clause).
As any database person knows, hints can either help or degrade the performance of queries. So, taking the SQL of the pre-hint Answer and figuring out which hints give the best
performance is suggested, prior to adding the hint fields/filters to the Answer.Hi Oliver,
I would suggest you to have a look at the below WLST script which would give you the required report of the active threads and it would be send an email too.
Topic: Sending Email Alert for Threads Pool Health Using WLST
http://middlewaremagic.com/weblogic/?p=5433
Topic: Sending Email Alert for Hogger Threads Count Using WLST
http://middlewaremagic.com/weblogic/?p=5423
Also you can use the below script in case of the stuck threads, this script would send you an email with the thread dumps during the issue occurred.
Topic: Sending Email Alert For Stuck Threads With Thread Dumps
http://middlewaremagic.com/weblogic/?p=5582
Regards,
Ravish Mody -
Cartesian of data from two tables with no matching columns
Hello,
I was wondering – what’s the best way to create a Cartesian of data from two tables with no matching columns in such a way, so that there will be only a single SQL query generated?
I am thinking about something like:
for $COUNTRY in ns0: COUNTRY ()
for $PROD in ns1:PROD()
return <Results>
<COUNTRY> {fn:data($COUNTRY/COUNTRY_NAME)} </COUNTRY>
<PROD> {fn:data($PROD/PROD_NAME)} </PROD>
</Results>
And the expected result is combination of all COUNTRY_NAMEs with all PROD_NAMEs.
What I’ve noticed when checking query plan is that DSP will execute two queries to have the results – one for COUNTRY_NAME and another one for PROD_NAME. Which in general results in not the best performance ;-)
What I’ve noticed also is that when I add something like:
where COUNTRY_NAME != PROD_NAME
everything is ok and there is only one query created (it's red in the Query plan, but still it's ok from my pov). Still it looks to me more like a workaround, not a real best approach. I may be wrong though...
So the question is – what’s the suggested approach for such queries?
Thanks,
Leszek
Edited by xnts at 11/19/2007 10:54 AMWhich in general results in not the best performanceI disagree. Only for two tables with very few rows, would a single sql statement give better performance.
Suppose there are 10,000 rows in each table - the cross-product will result in 100 million rows. Sounds like a bad idea. For this reason, DSP will not push a cross-product to a database. It will get the rows from each table in separate sql statements (retrieving only 20,000 rows) and then produce the cross-product itself.
If you want to execute sql with cross-products, you can create a sql-statement based dataservice. I recommend against doing so. -
Query to get the difference between 2 totals from 2 different queries
I wanted to know if it is possible to get the difference between 2 totals from 2 different queries. I would explain with an example:
1st query - Select sum(homepass) from table 1
2nd query – select sum(homepass) from table2
Is it possible to display the difference like-
Select sum(homepass) from table 1 - sum(homepass) from table2
I know the above query would gives syntax error but is there a better way or a trick to get the above task accomplished from a single query.
I hope, my question is clear.
Please revert with the reply to my query.
Regardstomernitin wrote:
Try this one also:
WITH adtn1
AS
SELECT 110 val1 FROM dual UNION ALL
SELECT 100 FROM dual UNION ALL
SELECT 90 FROM dual UNION ALL
SELECT 10 FROM dual
adtn2
AS
SELECT 10 val2 FROM dual UNION ALL
SELECT 20 FROM dual UNION ALL
SELECT 30 FROM dual UNION ALL
SELECT 100 FROM dual
SELECT(Sum(a1.val1)-Sum(a2.val2)) Diff FROM adtn1 a1,adtn2 a2;
let me know if you still have any doubt.
Um.... I don't think so. Not with the cartesian join between a1 and 2. -
Text index for UNION queries.
Hi All,
Can anyone please help me in tuning search query mentioned below
select id from usr1.organizations where lower(ID_official_name) like 'technology%'
union
select id from usr1.organizations where lower(ID_OFFICIAL_NORM_NAME) like 'technology%'
union
select id from usr1.organizations where lower(ID_OFFICIAL_ENG_NAME) like 'technology%'
union
select id from usr1.organizations where lower(ID_OFFICIAL_ENG_NORM_NAME) like 'technology%'
union
select id from usr1.organizations where lower(ID_OFFICIAL_TRANS_NAME) like 'technology%'
union
select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_NAME) like 'technology%'
union
select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_NORM_NAME) like 'technology%'
union
select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_ENG_NAME) like 'technology%'
union
select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_ENG_NORM_NAME) like 'technology%'
union
select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_TRANS_NAME) like 'technology%'
union
select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_dba_name) like 'technology%'
union
select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_NORM_NAME) like 'technology%'
union
select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_ENG_NAME) like 'technology%'
union
select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_ENG_NORM_NAME) like 'technology%'
union
select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_TRANS_NAME) like 'technology%'
union
select id from usr1.ID_FKA_NAMES where lower(ID_fka_name) like 'technology%'
union
select id from usr1.ID_FKA_NAMES where lower(ID_fkA_NORM_NAME) like 'technology%'
union
select id from usr1.ID_FKA_NAMES where lower(ID_fkA_ENG_NAME) like 'technology%'
union
select id from usr1.ID_FKA_NAMES where lower(ID_fkA_ENG_NORM_NAME) like 'technology%'
union
select id from usr1.ID_FKA_NAMES where lower(ID_fkA_TRANS_NAME) like 'technology%'Here organizations table is the parent table having primary key on id column, and rest all tables are children tables having foreign key on id column referencing to primary key id column in organizations table.
Planning to implement multiple column(Userdatastore) text index on dummy column appended to organizations table. And write triggers on other child tables to trigger the sync for Text index.
But not sure whether we can rewrite this above sql query by replacing union into joins, not sure why developer has not done so.
Can anyone please help me in creating text index for this sql. I do not want to approach cartesian joins as these are having parent-child relationship.
Oracle Version: 10.2.0.4
Please let me know if you need more information1 .As text index is created in parent table on id column, can we somehow search only from particular columns(Parent or child) by using user_datastore and tags for sectioning it?
Below are the sql which i need to make use of text index
select m.id from id_ALIAS_NAMEs an
join organizations m on(m.id=an.id)
where lower(ID_ALIAS_NAME) like 'technology%' and m.id_data_provider<100;
select M.id,ID_ALIAS_NAME,'ID_ALIAS_NAME' AS NAMETYPE
from id_alias_names an JOIN organizations m ON m.id=an.id
where id_data_provider<100 AND coalesce(m.ID_COUNTRY_OF_DOMICILE,m.ID_COUNTRY_OF_INCORPORATION)='US'
AND LOWER(ID_ALIAS_NAME) like LOWER('TECHNOLOGY%')
and F_GetFirstWord(ORG_ALIAS_NAME)='TECHNOLOGY'
The text index must be created on a text column, not a numeric id column. It is common to create it on a dummy column. You can name that column anything you like instead of dummy, like search_columns or some such thing. You can add tags in your procedure, so that your resulting virtual column is like xml data. You can then create a section group, so that you can search within each of those tags. In the example below, I used ctxsys.auto_section_group because it is the simplest to create, but you may get better performance by using another type of section group and naming each individual tag.
SCOTT@orcl_11gR2> -- tables you already have:
SCOTT@orcl_11gR2> create table organizations
2 (id number primary key,
3 id_official_name varchar2 (10),
4 id_official_norm_name varchar2 (10),
5 id_official_eng_name varchar2 (10),
6 id_official_trans_name varchar2 (10),
7 id_data_provider number,
8 id_country_of_domicile varchar2 (10),
9 id_country_of_incorporation varchar2 (10))
10 /
Table created.
SCOTT@orcl_11gR2> create table id_alias_names
2 (id number references organizations (id),
3 id_alias_name varchar2 (10),
4 id_alias_norm_name varchar2 (10),
5 id_alias_eng_name varchar2 (10),
6 id_alias_trans_name varchar2 (10))
7 /
Table created.
SCOTT@orcl_11gR2> create table id_doing_business_as_names
2 (id number references organizations (id),
3 id_dba_name varchar2 (10),
4 id_dba_norm_name varchar2 (10),
5 id_dba_eng_name varchar2 (10),
6 id_dba_trans_name varchar2 (10))
7 /
Table created.
SCOTT@orcl_11gR2> create table id_fka_names
2 (id number references organizations (id),
3 id_fka_name varchar2 (10),
4 id_fka_norm_name varchar2 (10),
5 id_fka_eng_name varchar2 (10),
6 id_fka_trans_name varchar2 (10))
7 /
Table created.
SCOTT@orcl_11gR2> -- test data:
SCOTT@orcl_11gR2> insert all
2 into organizations values (1, 'test', 'name2', 'name3', 'name4', 99, 'US', null)
3 into organizations values (2, 'name1', 'name2', 'name3', 'name4', 99, null, 'US')
4 into organizations values (3, 'name1', 'name2', 'name3', 'name4', 99, null, null)
5 into organizations values (4, 'name1', 'name2', 'name3', 'name4', 101, 'US', 'US')
6 into organizations values (5, 'technology', 'technology', 'technology', 'technology', 99, 'US', 'US')
7 select * from dual
8 /
5 rows created.
SCOTT@orcl_11gR2> insert all
2 into id_alias_names values (1, 'technology', 'name6', 'name7', 'name8')
3 into id_alias_names values (2, 'technology', 'test', 'name7', 'name8')
4 into id_alias_names values (3, 'technology', 'name6', 'name7', 'name8')
5 into id_alias_names values (4, 'technology', 'name6', 'name7', 'name8')
6 into id_alias_names values (5, 'name5', 'technology', 'technology', 'technology')
7 select * from dual
8 /
5 rows created.
SCOTT@orcl_11gR2> insert all
2 into id_doing_business_as_names values (1, 'name9', 'name10', 'name11', 'name12')
3 into id_doing_business_as_names values (2, 'name9', 'name10', 'name11', 'name12')
4 into id_doing_business_as_names values (3, 'name9', 'name10', 'test', 'name12')
5 into id_doing_business_as_names values (4, 'name9', 'name10', 'name11', 'name12')
6 into id_doing_business_as_names values (5, 'technology', 'technology', 'technology', 'technology')
7 select * from dual
8 /
5 rows created.
SCOTT@orcl_11gR2> insert all
2 into id_fka_names values (1, 'name13', 'name14', 'name15', 'name16')
3 into id_fka_names values (2, 'name13', 'name14', 'name15', 'name16')
4 into id_fka_names values (3, 'name13', 'name14', 'name15', 'name16')
5 into id_fka_names values (4, 'name13', 'name14', 'name15', 'test')
6 into id_fka_names values (5, 'technology', 'technology', 'technology', 'technology')
7 select * from dual
8 /
5 rows created.
SCOTT@orcl_11gR2> -- revised procedure to join tables with tags:
SCOTT@orcl_11gR2> create or replace procedure your_proc
2 (p_rowid in rowid,
3 p_clob in out nocopy clob)
4 as
5 begin
6 for r1 in
7 (select id,
8 '<id_official_name>'
9 || id_official_name
10 || '</id_official_name><id_official_norm_name>'
11 || id_official_norm_name
12 || '</id_official_norm_name><id_official_eng_name>'
13 || id_official_eng_name
14 || '</id_official_eng_name><id_official_trans_name>'
15 || id_official_trans_name
16 || '</id_official_trans_name>' as tags_and_values
17 from organizations
18 where rowid = p_rowid)
19 loop
20 dbms_lob.writeappend
21 (p_clob, length (r1.tags_and_values), r1.tags_and_values);
22 for r2 in
23 (select '<id_alias_name>'
24 || id_alias_name
25 || '</id_alias_name><id_alias_norm_name>'
26 || id_alias_norm_name
27 || '</id_alias_norm_name><id_alias_eng_name>'
28 || id_alias_eng_name
29 || '</id_alias_eng_name><id_alias_trans_name>'
30 || id_alias_trans_name
31 || '</id_alias_trans_name>' as tags_and_values
32 from id_alias_names
33 where id = r1.id)
34 loop
35 dbms_lob.writeappend
36 (p_clob, length (r2.tags_and_values), r2.tags_and_values);
37 end loop;
38 for r3 in
39 (select '<id_dba_name>'
40 || id_dba_name
41 || '</id_dba_name><id_dba_norm_name>'
42 || id_dba_norm_name
43 || '</id_dba_norm_name><id_dba_eng_name>'
44 || id_dba_eng_name
45 || '</id_dba_eng_name><id_dba_trans_name>'
46 || id_dba_trans_name
47 || '</id_dba_trans_name>' as tags_and_values
48 from id_doing_business_as_names
49 where id = r1.id)
50 loop
51 dbms_lob.writeappend
52 (p_clob, length (r3.tags_and_values), r3.tags_and_values);
53 end loop;
54 for r4 in
55 (select '<id_fka_name>'
56 || id_fka_name
57 || '</id_fka_name><id_fka_norm_name>'
58 || id_fka_norm_name
59 || '</id_fka_norm_name><id_fka_eng_name>'
60 || id_fka_eng_name
61 || '</id_fka_eng_name><id_fka_trans_name>'
62 || id_fka_trans_name
63 || '</id_fka_trans_name>' as tags_and_values
64 from id_fka_names
65 where id = r1.id)
66 loop
67 dbms_lob.writeappend
68 (p_clob, length (r4.tags_and_values), r4.tags_and_values);
69 end loop;
70 end loop;
71 end your_proc;
72 /
Procedure created.
SCOTT@orcl_11gR2> show errors
No errors.
SCOTT@orcl_11gR2> -- examples of virtual columns that revised procedure returns:
SCOTT@orcl_11gR2> declare
2 v_clob clob;
3 begin
4 for r in
5 (select rowid, id
6 from organizations)
7 loop
8 dbms_lob.createtemporary (v_clob, true);
9 your_proc (r.rowid, v_clob);
10 dbms_output.put_line (r.id);
11 dbms_output.put_line (v_clob);
12 dbms_lob.freetemporary (v_clob);
13 end loop;
14 end;
15 /
1
<id_official_name>test</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name3
</id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><i
d_alias_norm_name>name6</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_a
lias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>name11</id_d
ba_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_f
ka_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>name16</id_fka_trans_name>
2
<id_official_name>name1</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name
3</id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><
id_alias_norm_name>test</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_a
lias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>name11</id_d
ba_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_f
ka_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>name16</id_fka_trans_name>
3
<id_official_name>name1</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name
3</id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><
id_alias_norm_name>name6</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_
alias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>test</id_db
a_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_fk
a_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>name16</id_fka_trans_name>
4
<id_official_name>name1</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name
3</id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><
id_alias_norm_name>name6</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_
alias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>name11</id_
dba_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_
fka_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>test</id_fka_trans_name>
5
<id_official_name>technology</id_official_name><id_official_norm_name>technology</id_official_norm_name><id_official_eng
_name>technology</id_official_eng_name><id_official_trans_name>technology</id_official_trans_name><id_alias_name>name5</
id_alias_name><id_alias_norm_name>technology</id_alias_norm_name><id_alias_eng_name>technology</id_alias_eng_name><id_al
ias_trans_name>technology</id_alias_trans_name><id_dba_name>technology</id_dba_name><id_dba_norm_name>technology</id_dba
_norm_name><id_dba_eng_name>technology</id_dba_eng_name><id_dba_trans_name>technology</id_dba_trans_name><id_fka_name>te
chnology</id_fka_name><id_fka_norm_name>technology</id_fka_norm_name><id_fka_eng_name>technology</id_fka_eng_name><id_fk
a_trans_name>technology</id_fka_trans_name>
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> -- user_datastore:
SCOTT@orcl_11gR2> begin
2 ctx_ddl.create_preference ('your_datastore', 'user_datastore');
3 ctx_ddl.set_attribute ('your_datastore', 'procedure', 'your_proc');
4 end;
5 /
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> -- dummy column:
SCOTT@orcl_11gR2> alter table organizations add (dummy varchar2(1))
2 /
Table altered.
SCOTT@orcl_11gR2> -- index with auto_section_group,
SCOTT@orcl_11gR2> -- must be on a text column, like dummy, not numeric id column:
SCOTT@orcl_11gR2> create index your_index
2 on organizations (dummy)
3 indextype is ctxsys.context
4 parameters
5 ('datastore your_datastore
6 section group ctxsys.auto_section_group')
7 /
Index created.
SCOTT@orcl_11gR2> -- example queries:
SCOTT@orcl_11gR2> select id
2 from organizations
3 where contains (dummy, 'technology within id_alias_name') > 0
4 and id_data_provider < 100
5 /
ID
1
2
3
3 rows selected.
SCOTT@orcl_11gR2> select m.id, an.id_alias_name, 'ID_ALIAS_NAME' as nametype
2 from id_alias_names an join organizations m on m.id = an.id
3 where contains (m.dummy, 'technology within id_alias_name') > 0
4 and m.id_data_provider < 100
5 and coalesce (m.id_country_of_domicile, m.id_country_of_incorporation) = 'US'
6 /
ID ID_ALIAS_N NAMETYPE
1 technology ID_ALIAS_NAME
2 technology ID_ALIAS_NAME
2 rows selected.
SCOTT@orcl_11gR2> -
Joining DB VIEW and Command result in cartesian product
hello,
My SQL query is joining a DB view and a Command(=ad hoc query).
Nonetheless from the results it appears that CR didn't join the views correctly, it returns a cartesian product.
Any idea what the issue could be, I'm using very simple queries.
Thanks in advance#1 make sure you are linking everything together properly in the "Links" tab of the Database Expert
#2 In my experience, it's just a bad idea to join SQL commands and other tables. I had poor performance issues in my case. (It prevents server side filtering and grouping) My suggestion is to write out the entire thing in the command. If you are pulling from multiple database, write a separate command for each database and link them. -
General queries regarding explain plan and query
Hello Oracle buddies,
I have few badly formed queries with plenty of nested loops, merge join cartesian , plenty of sorting and in the query so many sub queries and all.. The cost of the queries are high like anything.
some even has 130Crore of cost .
When I got the chance to look into those quries I test them in Non Prod systems and which almost have 90-95% similar data as it was refresh by PROD few weeks back.
I found few queries are having the same explain plan but cost is less like anything. for example 5000 or 6000.
When I check for the possibilities of wrong statistics I found they just collect with default setting...
In Non prod I saw only the auto stat job is ran and most of the tables are having the stats which are of last analyzed on the day of refresh.
Now what could be so differentiating factor that drives a queries' cost lesser than Prod systems, when the data is almost same. Also if prod ssystem is gather by only gather_schema_stat('SCHEMA_NAME') then it should carry the same stat in non prod while refreshing. I know ppl do not gather stat on test only auto job is running ...
I need to have clear prove before I can have a clear understanding..
Please help me to know what factors could be differentiating?
-Regards,
J_DBA_Souravj_DBA_sourav wrote:
Hello Jonathan,
Thanks for the reply. The team refreshed it, by expdp/impdp method where by default statistics are included. In that case?
Is this problem probable to happen due to statistics only or anything else is also responsible. Even the explain plan is same.
Please through some light on it.
Auto job is on as I stated earlier but in test systems most of the tables are showing refreshed date as last_analyzed
-Regards
JDS
Anything that puts the stats out of sync with each other may be sufficient to cause problems. Any queries that depend on sysdate may cause a problem.
As a simple check: select table_name, last_analyzed from user_tables on the two systems, with some order by clause (e.g. table_name), and see how many tables were analysed at different times - anything on either system after the exp/imp could be part of your problem.
Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com
Now on Twitter: @jloracle -
Queries: duplicate info when executing a HR query
Hi.
Friends, i trying to do a query with info of two infotipes: 21 and 482 (aditional info of it21), when i execute the query the result it's a cartesian product (wrong result).
For example:
DATA
IT21
PERNR Subty Name
1 10 ssssss
2 11 dddddd
IT482
Pernr subty identity card
1 10 5
2 11 6
Result
Wrong Result with cartesian product of the query:
PERNR subty name it482-subty it482-identity card
1 10 ssssss 10 5
1 11 dddddd 10 5
1 10 ssssss 11 6
1 11 dddddd 11 6
The correct result must be:
PERNR subty name it482-subty it482-identity card
1 10 ssssss 10 5
1 11 dddddd 11 6
I think that the join of the PNPCE logical database it's performed using just personel number (pernr), how could i solve this issue?
Thanks in advance.
Albio.-
Solved in HCM Forum: Re: Queries: duplicate info when executing a HR query
Edited by: Albio Manuel Vivas on Aug 16, 2011 7:35 PMI found where to put the switch, but it doesn't work.
I did this:
1) in the infogroup (tx sq02): goto/ code / data. Then i typed:
*$HR$ [P0482]
*$HR$ PRIMARY_INFTY = 'P0021'
2) save
3) verify
4) generate
Then i use the transaction S_PH0_48000513 - Ad-hoc-Query , and create a query, i save it, and execute, then the result it's wrong. I check the program generated by the query, and search for this text: 'hr-log' where are supposed that the code must appears, and the code that i added doesn't exits.
Any idea?
Thanks in advance.
Albio.-
Edited by: Albio Manuel Vivas on Aug 16, 2011 6:14 PM -
Logical equivalence of 2 queries
Hi All,
I dont know whether this is right question but I am not sure so putting it here.
I have one query which I am trying to tune which I felt is doing unnecessary fetches and additional joins not required ( here I do nt know the backgrnd of this query like purpose etc. still given for tuning)
Hence I rewritten same query which I feel is logical equivalent of the original query. Thus need your guidance.
This is original query:
WITH
fi as (select feed_book_status.COB_DATE,
feed_book_status.FEED_INSTANCE_ID,BOOK_ID , feed_id
from feed_book_status, feed_instance
where feed_book_status.cob_date = v_cob_date
and feed_book_status.FEED_INSTANCE_ID=feed_instance.FEED_INSTANCE_ID
AND FEED_BOOK_STATUS.COB_DATE= FEED_INSTANCE.COB_DATE
p as (select book_id, feed_instance_id, position_id from position where feed_instance_id in
(select feed_instance_id from fi)),
s as (select book_id, position_id, feed_instance_id, type_id from sensitivity where feed_instance_id in
(select feed_instance_id from fi))
select
fi.cob_date, fi.feed_id, p.book_id, s.type_id, count(s.book_id) Cnt
from fi
inner join p on p.feed_instance_id = fi.feed_instance_id and fi.book_id = p.book_id
inner join s on p.feed_instance_id = s.feed_instance_id and p.position_id = s.position_id
group by fi.cob_date, fi.feed_id, p.book_id, s.type_id;Execution plan
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Pstart| Pstop |
| 0 | SELECT STATEMENT | | 40730 | 4613K| | 65255 (17)| | |
| 1 | TEMP TABLE TRANSFORMATION | | | | | | | |
| 2 | LOAD AS SELECT | SENSITIVITY | | | | | | |
|* 3 | HASH JOIN | | 240 | 9600 | | 32 (7)| | |
| 4 | TABLE ACCESS BY INDEX ROWID| FEED_INSTANCE | 238 | 4284 | | 12 (0)| | |
|* 5 | INDEX RANGE SCAN | IDX_FEED_INSTANCE_CD_MR | 238 | | | 3 (0)| | |
|* 6 | INDEX RANGE SCAN | IDX_FBS_CD_FII_BI | 2981 | 65582 | | 19 (6)| | |
| 7 | HASH GROUP BY | | 40730 | 4613K| 138M| 65223 (17)| | |
|* 8 | HASH JOIN | | 1073K| 118M| 9848K| 57613 (18)| | |
|* 9 | HASH JOIN | | 113K| 8515K| | 14875 (13)| | |
| 10 | VIEW | | 240 | 6720 | | 2 (0)| | |
| 11 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6813_D59D2159 | 240 | 6720 | | 2 (0)| | |
|* 12 | HASH JOIN | | 3854K| 180M| | 14555 (11)| | |
| 13 | MERGE JOIN CARTESIAN | | 240 | 2400 | | 496 (3)| | |
| 14 | VIEW | VW_NSO_2 | 240 | 1200 | | 2 (0)| | |
| 15 | HASH UNIQUE | | 240 | 3120 | | | | |
| 16 | VIEW | | 240 | 3120 | | 2 (0)| | |
| 17 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6813_D59D2159 | 240 | 6720 | | 2 (0)| | |
| 18 | BUFFER SORT | | 240 | 1200 | | 2 (-240| | |
| 19 | VIEW | VW_NSO_1 | 240 | 1200 | | 2 (0)| | |
| 20 | HASH UNIQUE | | 240 | 3120 | | | | |
| 21 | VIEW | | 240 | 3120 | | 2 (0)| | |
| 22 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6813_D59D2159 | 240 | 6720 | | 2 (0)| | |
| 23 | PARTITION RANGE ALL | | 3854K| 143M| | 13741 (9)| 1 | 130 |
| 24 | TABLE ACCESS FULL | POSITION | 3854K| 143M| | 13741 (9)| 1 | 130 |
| 25 | PARTITION RANGE ALL | | 18M| 691M| | 21789 (22)| 1 | 130 |
| 26 | TABLE ACCESS FULL | SENSITIVITY | 18M| 691M| | 21789 (22)| 1 | 130 |
Predicate Information (identified by operation id):
3 - access("FEED_BOOK_STATUS"."FEED_INSTANCE_ID"="FEED_INSTANCE"."FEED_INSTANCE_ID" AND
"FEED_BOOK_STATUS"."COB_DATE"="FEED_INSTANCE"."COB_DATE")
5 - access("FEED_INSTANCE"."COB_DATE"=TO_DATE(' 2010-10-12 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
6 - access("FEED_BOOK_STATUS"."COB_DATE"=TO_DATE(' 2010-10-12 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
8 - access("FEED_INSTANCE_ID"="FEED_INSTANCE_ID" AND "POSITION_ID"="POSITION_ID" AND
"FEED_INSTANCE_ID"="$nso_col_1")
9 - access("FEED_INSTANCE_ID"="FI"."FEED_INSTANCE_ID" AND "FI"."BOOK_ID"="BOOK_ID")
12 - access("FEED_INSTANCE_ID"="$nso_col_1")This one new query
WITH
fi as (select feed_book_status.COB_DATE,
feed_book_status.FEED_INSTANCE_ID,BOOK_ID , feed_id
from feed_book_status, feed_instance
where feed_book_status.cob_date = '12-Oct-2010'
and feed_book_status.FEED_INSTANCE_ID=feed_instance.FEED_INSTANCE_ID
AND FEED_BOOK_STATUS.COB_DATE= FEED_INSTANCE.COB_DATE
select fi.cob_date, fi.feed_id, p.book_id, s.type_id, count(s.book_id) Cnt
from fi, position p, sensitivity s
where p.feed_instance_id = fi.feed_instance_id
and p.book_id= fi.book_id
and p.feed_instance_id = s.feed_instance_id
and p.position_id = s.position_id
group by fi.cob_date, fi.feed_id, p.book_id, s.type_idExecution plan
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Pstart| Pstop |
| 0 | SELECT STATEMENT | | 157 | 18526 | 1380 (14)| | |
| 1 | HASH GROUP BY | | 157 | 18526 | 1380 (14)| | |
|* 2 | TABLE ACCESS BY LOCAL INDEX ROWID | SENSITIVITY | 2276 | 88764 | 6 (0)| | |
| 3 | NESTED LOOPS | | 255K| 28M| 1209 (2)| | |
| 4 | NESTED LOOPS | | 112 | 8848 | 533 (3)| | |
|* 5 | HASH JOIN | | 240 | 9600 | 32 (7)| | |
| 6 | TABLE ACCESS BY INDEX ROWID | FEED_INSTANCE | 238 | 4284 | 12 (0)| | |
|* 7 | INDEX RANGE SCAN | IDX_FEED_INSTANCE_CD_MR | 238 | | 3 (0)| | |
|* 8 | INDEX RANGE SCAN | IDX_FBS_CD_FII_BI | 2981 | 65582 | 19 (6)| | |
| 9 | PARTITION RANGE ITERATOR | | 1 | 39 | 14 (0)| KEY | KEY |
| 10 | TABLE ACCESS BY LOCAL INDEX ROWID| POSITION | 1 | 39 | 14 (0)| KEY | KEY |
|* 11 | INDEX RANGE SCAN | IDX_RISK_POSITION_FII_BI | 172 | | 2 (0)| KEY | KEY |
| 12 | PARTITION RANGE ITERATOR | | 5 | | 2 (0)| KEY | KEY |
|* 13 | INDEX RANGE SCAN | IDX_SENSITIVITY_RPI | 5 | | 2 (0)| KEY | KEY |
Predicate Information (identified by operation id):
2 - filter("P"."FEED_INSTANCE_ID"="S"."FEED_INSTANCE_ID")
5 - access("FEED_BOOK_STATUS"."FEED_INSTANCE_ID"="FEED_INSTANCE"."FEED_INSTANCE_ID" AND
"FEED_BOOK_STATUS"."COB_DATE"="FEED_INSTANCE"."COB_DATE")
7 - access("FEED_INSTANCE"."COB_DATE"=TO_DATE(' 2010-10-12 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
8 - access("FEED_BOOK_STATUS"."COB_DATE"=TO_DATE(' 2010-10-12 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
11 - access("P"."FEED_INSTANCE_ID"="FEED_BOOK_STATUS"."FEED_INSTANCE_ID" AND "P"."BOOK_ID"="BOOK_ID")
13 - access("P"."POSITION_ID"="S"."POSITION_ID")This is Oracle version 10.2.
Rgds,
AashishAashish S. wrote:
This is original query:
WITH
fi as (select feed_book_status.COB_DATE,
feed_book_status.FEED_INSTANCE_ID,BOOK_ID , feed_id
from feed_book_status, feed_instance
where feed_book_status.cob_date = v_cob_date
and feed_book_status.FEED_INSTANCE_ID=feed_instance.FEED_INSTANCE_ID
AND FEED_BOOK_STATUS.COB_DATE= FEED_INSTANCE.COB_DATE
p as (select book_id, feed_instance_id, position_id from position where feed_instance_id in
(select feed_instance_id from fi)),
s as (select book_id, position_id, feed_instance_id, type_id from sensitivity where feed_instance_id in
(select feed_instance_id from fi))
select
fi.cob_date, fi.feed_id, p.book_id, s.type_id, count(s.book_id) Cnt
from fi
inner join p on p.feed_instance_id = fi.feed_instance_id and fi.book_id = p.book_id
inner join s on p.feed_instance_id = s.feed_instance_id and p.position_id = s.position_id
group by fi.cob_date, fi.feed_id, p.book_id, s.type_id;This one new query
WITH
fi as (select feed_book_status.COB_DATE,
feed_book_status.FEED_INSTANCE_ID,BOOK_ID , feed_id
from feed_book_status, feed_instance
where feed_book_status.cob_date = '12-Oct-2010'
and feed_book_status.FEED_INSTANCE_ID=feed_instance.FEED_INSTANCE_ID
AND FEED_BOOK_STATUS.COB_DATE= FEED_INSTANCE.COB_DATE
select fi.cob_date, fi.feed_id, p.book_id, s.type_id, count(s.book_id) Cnt
from fi, position p, sensitivity s
where p.feed_instance_id = fi.feed_instance_id
and p.book_id= fi.book_id
and p.feed_instance_id = s.feed_instance_id
and p.position_id = s.position_id
group by fi.cob_date, fi.feed_id, p.book_id, s.type_idExecution plan
The two queries don't seem to be equivalent - take subquery P as an example:
because of the IN subquery, every row in POSITION can appear no more than once in P, but when you turn the subquery into a join each row in POSITION may appear many times because there may be many row in FI with the same feed_instance_id.
Part of you performance problem may relate to the fact that the optimizer suffers from a few defects when optimising code that uses subquery factoring ( http://jonathanlewis.wordpress.com/2010/09/13/subquery-factoring-4/ ) ; it also has problems with ANSI SQL.
For testing purposes, I would try the following:
Step 1 - copy the P and S subqueries inline and see how the plan changes. (My guess would be that Oracle would still do a temp table transformation and create a result set for for FI and use it three times - but it's possible that it would do something a little more sensible with POSITION and SENSITIVITY
Step 2 - as step 1, but add the /*+ inline */ hint to the definition of FI to force Oracle to copy the code in-line rather than creating a temp table (assuming this hasn't happened in step 1)
Step 3 - copy the FI code inline three times.
Step 4a - assuming the rewrite performs well, document it, consider whether you want to make it look prettier and more understandable.
Step 4b - assuming the rewrite doesn't perform weel, start thinking about logical equivalence. Watch out particularly for the implied "select distinct" from IN subqueries, and check what uniqueness constraints you have on the data. (It's possible that your rewrite is actually equivalent because of uniqueness constraints on the data that you havevn't told us about).
Regards
Jonathan Lewis -
Cross tab data is getting multiplied if i use multiple queris in asingle report
HI,
i am using multiple queris for displaying data and graphs(charts).
my requirement is to display 2 charts and data in crosstab in a single report.
all the three thing (2charts and crosstab) will use diffrent values.
I am writing 3 sql queries for getting appropriate values for charts and crosstab.
Now the problem, both charts and crosstab are taking the values of all 3 queris
i.e if i added crosstab first to the report values are coming correctly. After that if i add graph cross tab values are getting changed and graph values are not getting properly.
if i add graph first then its coming correctly.
if i tried to add all 3 components then values are going cores...... ?When you say you are writing 3 sql queries what do you mean? Are you creating 3 SQL command objects in the database expert? If so this is your problem, Crystal will pull a cartesian product through (this is every possible combinatin of rows from the 3 queries).
If your 2 graphs and 1 crosstab are based on different datasets the way to approach this is to create each on a seperate report, then create a new blank report and add each of your 3 reports as subreports in the report footer.
Hope this helps,
Toby -
WHERE clauses and Merge Join Cartesian?
For some reason, Siebel is generating queries like this:
AND CONCAT (CONCAT (t41828.lvl8anc_postn, '-'),
t41828.lvl8_emp_full_name
) = 'GEO-SMITH, BILL'
AND CONCAT (CONCAT (t41828.lvl6anc_postn, '-'),
t41828.lvl6_emp_full_name
) = 'GROUP1-DOE, JOHN'and this ends up with 3 merge join cartesian in autotrace and this query takes several hours.
However, by rewriting just those 2 clauses to:
AND (t41828.lvl8anc_postn = 'GEO' and
t41828.lvl8_emp_full_name = 'SMITH, BILL')
AND (t41828.lvl6anc_postn = 'GROUP1' and
t41828.lvl6_emp_full_name = 'DOE, JOHN')the merge join cartesians go away, and it runs in 7 seconds.
However, since Siebel is generating the query, and we are having issues, we decided to add columns for testing that is equivalent to the concatenation of the two columns above. After doing this, and creating indexes on the new columns, it is now back to the merge join cartesian and I cannot get rid of it.
So:
1. How can rewriting the WHERE (not adding or deleting anything here, just rewriting it in a different way) clause eliminate the merge join cartesian?
I'm guessing by understanding that single question, I will be able to come up with a better solution to this.Note we made two additional columns:
CONCAT (CONCAT (t41828.lvl8anc_postn, '-'), t41828.lvl8_emp_full_name) => col1 CONCAT (CONCAT (t41828.lvl6anc_postn, '-'), t41828.lvl6_emp_full_name) => col2
When I created indexes on col1 and col2 and used them in the query, the cartesians returned, and I cannot figure out why. So, I'm still confused why:
In the original query:
1. Using CONCAT, and thus no indexes => cartesian
2. No CONCAT, and indexes => no cartesian
With the new columns, col1 and col2:
1. No CONCAT needed, full table scan or indexes => cartesian -
Extensive IO and CPU for simple queries
Hi,
I have a machine using oracle 9.2.0 and solaris 10.
For every simple queries, it very big IO and a lot of CPU. This is only happend on one particular machine(We have same version db and soalris on other mahcine and it works fine).
One example queris is when I use Enterprise Manager to get the "configuration" information of the instance,it use 50% IO. I get the trace file and tkprof as following:
SELECT UNIQUE sp.name, sp.sid, DECODE(p.type, 1, 'Boolean', 2, 'String', 3,'Integer', 4, 'Filename', ' '), sp.value, p.issys_modifiable, p.description FROM v$spparameter sp, v$parameter p WHERE sp.name = p.name ORDER BY sp.name,sp.sid
call count cpu elapsed disk query current rows
Parse 4 0.02 0.01 0 0 0 0
Execute 4 0.00 0.00 0 0 0 0
Fetch 9 4.36 34.12 7980 0 0 783
total 17 4.38 34.13 7980 0 0 783
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 5 (SYSTEM)
Rows Row Source Operation
261 SORT UNIQUE (cr=0 pr=0 pw=0 time=1214116 us)
261 HASH JOIN (cr=0 pr=0 pw=0 time=1221296 us)
361485 MERGE JOIN CARTESIAN (cr=0 pr=0 pw=0 time=370609 us)
261 FIXED TABLE FULL X$KSPSPFILE (cr=0 pr=0 pw=0 time=19777 us)
361485 BUFFER SORT (cr=0 pr=0 pw=0 time=6413 us)
1385 FIXED TABLE FULL X$KSPPCV (cr=0 pr=0 pw=0 time=4180 us)
1379 FIXED TABLE FULL X$KSPPI (cr=0 pr=0 pw=0 time=7001 us)
It seems Oracle FTS the X$KSPPCV and X$KSPPI.
Can anybody give me some suggestion to improve the performance?
thanks.Is there a difference in the query plans on the two machines?
Did you analyze the SYS and SYSTEM schemas on one system and not the other?
Are there different initialization parameters on the two machines?
What do you mean by "it use 50% IO"? I'm not sure what that means and I'm not sure how you're measuring that.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Join 3 tables or series of queries... need help asap
hi guys here's my case...
i have 3 tables, t1, t2 & t3 with the ff. columns...
t1.acct_no | t1.acct_stat | ....
1234 D
t2.acct_no | t2.rdg_date | t2.rdg | ....
1234 5.5.2008 30
1234 4.5.2008 28
t3.acct_no | t3.cur_rdg_date | t3.cur_rdg | ....
1234 5.7.2008 35
1234 4.6.2008 30
t1.acct_stat is where my main condition will be where. all accounts with acct_stat = 'D' will be processed...
as a sample, i have acct_no '1234'. i need to display only 1 record for acct_no '1234' including data from t2.rdg_date, t2.rdg_reading also t3.cur_rdg_date and t3.cur_rdg. in additon to this, i only need the maximum value of t2.rdg_date with the corresponding data from t2.rdg. also same with t3.cur_rdg_date and corresponding data in t3.cur_rdg.
how can you help me with this? the database is so big and contains 100,000+ (more or less) records with each tables... t1, t2 and t3. i've tried some some queries but when not getting a cartesian error, my toad is not responding.
thank you...Ok,
You need only 1 record of t2 (for each record of t1 of course)
So for t2 you need this:
select t2.rdg
from t2
where t2.rdg_date=
(select max(t2.rdg_date)
from t2a
where t2a.acct_no = t2.acct_no)
This subquery is called a 'correlated subquery' because t2.acct_no in the subquery refers to the main query.
You need a similar query for t3, replacing t2 by t3.
I will demonstrate the join between t1 and t2
select t1.acct_no, t2.rdg
from t1, t2
where t2.rdg_date=
(select max(t2.rdg_date)
from t2a
where t2a.acct_no = t2.acct_no)
and t2.acct_no(+)=t1.acct_no
'Not responding' is normal because you are waiting for the database server, and/or the thread running your session on your own system.
It will be slow due to the twofold outer joins you have between t1 and t2 and t1 and t3. Oracle will usually process the tables not involved in the outer join first.
If your column acct_stat in t1 isn't indexed, this will result in the complete table being processed and the result being filtered afterwards.
This can be a problem on your system, but as you don't post a database version, nor which optimiser you are using (Oracle has 2, and the default one hasn't been updated since 1994), nor any information on your system, I can't answer that question,
Sybrand Bakker
Senior Oracle DBA
Maybe you are looking for
-
Sales Order Report Showing Cost on the Sales Order & total invoice dollars
I am looking for a report in SAP that shows you the Sales Order number, the cost on the sales order (NOT the average cost) the actual cost on the sales order detail line and then the total invoice dollars in month to date and year to date? Thanks, Li
-
SanDisk eject error message and improper upload of pictures Aperture 3
My Macbook Pro seems to corrupt or damage SanDisks. I just uploaded a 16 GB disk which only uploaded about 30 out of 400 pictures into Aperture 3. It was a new disk. At first it showed all the pictures and looked as if it downloaded. When I ejecte
-
Problem configuring SSO: "Oracle SSO Warning - Unable to process request"
I'm having difficulty getting a sample application to work with SSO, and I was hoping someone could point me in to the right direction. We've got 2 separate systems, call them ASserver and SSOserver. ASserver is running Oracle 9i AS, SSOserver is the
-
I've been trying like for the tenth time to update my Iphone IOS and I just can't. It takes some time for Itunes to download the available IOS and when it's almost downloaded, an error occurs, saying that the time for downloading is over. How come? I
-
What needs to be in my jndi.properties file to get oracle accessed by a jndi client
I am trying to write a connection pool class that use jndi to locate the data base. I use "bindds" bind my OracleDataSource object with the name of 'test/jdbc/test'. I should then be able to do a lookup like: OracleDataSource ods = (OracleDataSource)