A sql query that take forever to finish it's execution
hi,
i am using oracle 10g/RedHat Entreprise linux 5.
i turn to you to help understand some odd behavior of a sql statement.
when i execute this statement:
create table ps_m_instop_profil NOLOGGING parallel(degree 3) as
SELECT b.topinstprodid AS insp, ltrim(rtrim(c.attr_item_id||c.attribute_value)) AS profil,
d.inst_prod_status AS statuts
FROM sysadm.ps_rf_attr_insp@DBCRM c,
sysadm.ps_rf_inst_prod_st@DBCRM d,
sysadm.ps_rf_inst_prod@DBCRM b,
sysadm.ps_rb_attribute@DBCRM e
WHERE c.attribute_id IN
('PPSPROFILE_X',
'PPSPROFILE_Y',
'PPSPROFILE_E',
'PPSPROFILE',
'PPSPROFILE_G1','INPROFILE_O','INPROFILE_U')
AND b.inst_prod_id = c.inst_prod_id
AND e.attribute_id = c.attribute_id
AND e.m_crm_attr_typage = 'M_PROFILE'
AND b.topinstprodid = d.inst_prod_id
AND d.inst_prod_status = 'INS';
if the number of ligne returned is small aproximatively 10000 the request end.
if the number of line is 13500000 (the number that should be returned +/- some thousand raws) the request hang indefinitely.
i am asking if it's due to some problems due to the dblinks then what should i check and how can i fix it.
this statement is very important it's the first step in my plsql script and if the request don't end normaly i can't continue the execution of the script.
thank you in advance.
As you are creating a table, could you not just create a table for each of your database links
eg
create table ps_rf_attr_insp as select * from sysadm.ps_rf_attr_insp@DBCRM;
create table ps_rf_inst_prod_st as sysadm.ps_rf_inst_prod_st@DBCRM;
create table ps_rf_inst_prod_st as sysadm.ps_rf_inst_prod@DBCRM;
create table ps_rb_attribute as sysadm.ps_rb_attribute@DBCRM;and then all your queries can run locally,
plus you can any appropriate indexes etc
Similar Messages
-
Reg: sql query that prints all sundays in the year
Hi all,
Please give me sql query that prints all sundays in year. And when ever we execute that query then that will prints the sysdate(that is execution date).
Thanks in Advance,
-prasad.
Edited by: prasad_orcl on Jun 5, 2009 9:13 PMHi,
Plz try this and let me know this works or not...
SELECT DATE DATES,TO_CHAR(DATE,'DAY') DAYS FROM FISCAL_CALENDAR
WHERE DATE_YEAR = 2009 AND
DATE BETWEEN TRUNC(SYSDATE,'YEAR') AND
ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),12) -1 AND
TRIM(TO_CHAR(DATE,'DAY')) = 'SUNDAY'
ORDER BY DATE
OUTPUT:
DATES DAYS
1/4/2009 SUNDAY
1/11/2009 SUNDAY
1/18/2009 SUNDAY
1/25/2009 SUNDAY
2/1/2009 SUNDAY
2/8/2009 SUNDAY
2/15/2009 SUNDAY
2/22/2009 SUNDAY
3/1/2009 SUNDAY
3/8/2009 SUNDAY
3/15/2009 SUNDAY
3/22/2009 SUNDAY
3/29/2009 SUNDAY
4/5/2009 SUNDAY
4/12/2009 SUNDAY
4/19/2009 SUNDAY
4/26/2009 SUNDAY
5/3/2009 SUNDAY
5/10/2009 SUNDAY
5/17/2009 SUNDAY
5/24/2009 SUNDAY
5/31/2009 SUNDAY
6/7/2009 SUNDAY
6/14/2009 SUNDAY
6/21/2009 SUNDAY
6/28/2009 SUNDAY
7/5/2009 SUNDAY
7/12/2009 SUNDAY
7/19/2009 SUNDAY
7/26/2009 SUNDAY
8/2/2009 SUNDAY
8/9/2009 SUNDAY
8/16/2009 SUNDAY
8/23/2009 SUNDAY
8/30/2009 SUNDAY
9/6/2009 SUNDAY
9/13/2009 SUNDAY
9/20/2009 SUNDAY
9/27/2009 SUNDAY
10/4/2009 SUNDAY
10/11/2009SUNDAY
10/18/2009SUNDAY
10/25/2009SUNDAY
11/1/2009 SUNDAY
11/8/2009 SUNDAY
11/15/2009SUNDAY
11/22/2009SUNDAY
11/29/2009SUNDAY
12/6/2009 SUNDAY
12/13/2009SUNDAY
12/20/2009SUNDAY
12/27/2009SUNDAY
Regards
Thiyag -
Need to write a query that takes more than 2 minutes to execute
Hi ,
I am using Oracle 10g as my DataBase.
I am writing a small program for Testing purpose , in that my requirement is to write a query that takes more than 2 minutes to execute .Right now i have only a small Table called as "Users" with very less data .
Please let me know how can i achieve this thing ??
Thanks .So please tell me , how can i achieve this . Thanks in advance .P. Forstman's example above will probably be more reliable, but here's an example of my idea - harder to control timing (untested)
select count(*)
from dba_objects o, dba_tables t, dba_tab_columns tc
where o.object_name||'' = t.table_name||''
and o.owner||'' = t.owner||''
and t.table_name||'' = tc.table_name
and t.owner||'' = tc.owner||'' -
Hi
I am trying to wright a SQL query that will return the date the timesheet was submitted and date/time it was approved, can anyone guide me on this?
I basically need person name who submitted, date - time it was submitted for approval, then the person who approved it and the date - time that it was approved
Thanks
RubyRuby,
you can start with HXC_TIMECARD_SUMMARY table for submitter detail. But for approver details, i think you need WF tables to get the data for item type HXCEMP. -
Need Sql Query that Suppress the repeating rows.
Hi Sir,
I have below data set.
DeptID Sum(SAL) Avg(Sal)
10 1300 1300
10 2450 1300
10 5000 1300
20 800 800
20 1100 800
20 2975 800
20 3000 800
30 800 800
30 1100 800
30 2975 800
40 3000 800
40 4000 900
I Need SQL query that can remove the duplicate or suppress.Just like below data set.
Output:
DeptID Sum(SAL) Avg(Sal)
10 1300 1300
2450 1300
5000 1300
20 800 800
1100 800
2975 800
3000 800
800 800
30 1100 800
2975 800
40 3000 800
4000 900
Could you please help me on this..Your requiremnt is more of a reporting request which should not be handled in SQL. For example in SQL Plus you can use the BREAK command
SQL> break on deptno
SQL> select deptno, ename from emp order by deptno;
DEPTNO ENAME
10 KING
CLARK
20 JONES
SCOTT
SMITH
ADAMS
30 TURNER
MARTIN
WARD
ALLEN
BLAKE
11 rows selected.
SQL>
But if you still wish to do it in SQL you can use ROW_NUMBER analytic function and achieve it like this
select decode(rno, 1, deptno) deptno
, ename
from (
select row_number() over(partition by deptno order by ename) rno
, deptno
, ename
from emp -
Since updating to ios7 my ipad freezes, randomly zooms in and out, black pages that take forever to load and battery charge doesn't last very long. It's very frustrating, is there anything I can do it seems to have a mind of its own
(A) Reset iPad
Hold down the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears
Note: Data will not be affected.
(B) Reset all settings
Settings>General>Reset>Reset all settings
Note: Data will not be affected but settings will be reset. -
Get column names into a VB program, for an SQL query that joins tables
use [mydatabase]
select * from InvNum inum
left join _btblInvoiceLines ilin
on inum.autoindex = ilin.iinvoiceid
left join stkitem s
on ilin.istockcodeid = s.stocklink where InvNumber = 'IVQ0834' or InvNumber = 'IVQ0835'
I need to get out the column names in a VB program in the same order they would appear in the SQL query above...
I want to use something like:
select column_name from information_schema.columns where TABLE_NAME = ....
except there are several tables involved above so I dont know the format!If you execute the query in your program using the SqlDataReader.ExecuteReader method, the column names will be available via the GetName method of the returned reader. But note that your query may return multiple columns with the same name.
Dim reader As SqlDataReader = command.ExecuteReader()
For x = 0 To reader.FieldCount - 1
Console.WriteLine(reader.GetName(x))
Next x
Dan Guzman, SQL Server MVP, http://www.dbdelta.com -
PL/SQL query that has a link to other website
I want to do a query that list books info (Date published, name, category, etc). The part I can't figure out is how would I create an HTML link on the "Name?" The website is on a separate server (i.e. http://mybookstore.com). The links are in the table with the Name and category.
I would like to use PL/SQL or Java (but prefer PL/SQL).
Any help would be appreciated.
KenHi Ken,
try the following for the query .....
select category , <A href = 'target_page'>name </A>, date_published from table_name;
Where exactly you want to use the query ... Is it for a report in Portal ...
Regds..
Sajith -
SQL query that returns exclusive rows from groups
I'm using modified scott/tiger data for this.
I've got two tables
DEPT_X
DEPTNO DNAME LOC CODE_ID SUB_DEPTNO
10 ACCOUNTING NEW YORK 111 101
10 SALES ATWN 111 102
10 SALES BTWN 112 103
20 RESEARCH DALLAS 111 201
20 RESEARCH CTWN 111 202
30 SALES CHICAGO 111 301
40 OPERATIONS BOSTON 112 401and
BI_PD
CODE_ID PD_TYPE BI_TYPE
111 -1
112 -1 I want to write a query that joins the code_ids of the two tables and lists out either only the records from DEPT_X who's code_ids have a -1 in the PD_TYPE(112) column and none of the code_ids that have a -1 in the BI_TYPE(111) column for each department or if that department has code_ids for the BI_TYPE (111), list out those rows. So for Deptno 10 you'll only get the row with SUB_DEPTNO = 103. But if for that DEPTNO= 20 you'll get the rows for both SUB_DEPTNO = 201 and 202.
So the result should look like
DEPTNO SUB_DEPTNO
10 103
20 201
20 202
30 301.
Basically I just want rows from each department that have code_ids = 111 not to show up if there are code_ids = 112.
What is the query to do this?
Message was edited by:
user623359
Message was edited by:
user623359
Message was edited by:
user623359
Message was edited by:
user623359
Message was edited by:
user623359One way could be:
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
SQL> with dept_x as (
2 select 10 deptno, 'ACCOUNTING' dname, 'NEW YORK' loc, 111 code_id, 101 sub_deptno from dual
union all
3 select 10, 'SALES', 'ATWN', 111, 102 from dual union all
4 select 10, 'SALES', 'BTWN', 112, 103 from dual union all
5 select 20, 'RESEARCH', 'DALLAS', 111, 201 from dual union all
6 select 20, 'RESEARCH', 'CTWN', 111, 202 from dual union all
7 select 30, 'SALES', 'CHICAGO', 111, 301 from dual union all
8 select 40, 'OPERATIONS', 'BOSTON', 112, 401 from dual ),
9 --
10 bi_pd as(
11 select 111 code_id, null pd_type, -1 bi_type from dual union all
12 select 112, -1, null from dual),
13 --
14 t as(
15 select a.deptno,a.sub_deptno from dept_x a, bi_pd b
16 where a.code_id = b.code_id and b.pd_type = -1)
17 --
18 select a.deptno,a.sub_deptno
19 from dept_x a, bi_pd b
20 where a.code_id = b.code_id and b.bi_type = -1 and
21 (a.deptno) not in (select deptno from t)
22 union
23 select deptno,sub_deptno from t;
DEPTNO SUB_DEPTNO
10 103
20 201
20 202
30 301
40 401 -
Started after last auto update several days ago. A few other sites are slow to load while many are good but Facebook just won't present it's usual mix of pre-programmed scripts and links but comes up eventually as part HTML script with a log-in box and when you log-in it then takes forever again and just gives HTML type script for "Friends" "messages" etc. but if you click these it goes nowhere!
Also it won't let me clear history at all despite many tries. I removed and reloaded the program last night but no positive effect.I still haven't resolved this problem. Here is some more information...
youtube is the only website that has started working, but it sometimes stops working again.
There are many other sites that don't work, cnn.com, washingtonpost.com (sometimes), and a lot of others.
I have contacted our internet service provider and they said that they had nothing to do with the problem.
Some websites will not work at all. Safari tells me that it can't find the server. Some that do this are ups.com, computerworld.com, and others.
I think that the problem is that, for some reason, our mac computers can't access certain servers where we are. (We are at a small ski resort (on the mountain) in Canada.) I think this because when a site doesn't load properly there are several errors and they are all "can't find host" errors from a couple of the same sites (ex. example.something.something).
*Also, I ran a test on speedtest.net on the laptop and one of our iMacs and the results were way faster than anything actually loads/downloads or than the activity monitor shows, even when checking the activity monitor at the same time as running the test. -
SQL- Query that return only one record
Hello,
is it possible to execute a pure SQL-Query which returns only one row although multiple rows are found.
It is no problem in PL/SQL, but I have no idea if the same is also possible in SQL.
thanks in advance
MichaelWhy not? There are 4 records in this table, but only selected one.
SQL> with t
2 as
3 (
4 select '#%$@#$@$@##$' Addr from dual
5 union all
6 select '18 Jalan Scott' from dual
7 union all
8 select '18 Lemana St' from dual
9 union all
10 select '32-penstation' from dual
11 union all
12 select '99999999999' from dual
13 )
14 select addr
15 from t
16 where rownum =1
17 /
ADDR
#%$@#$@$@##$
SQL>Cheers
Sarma. -
SQL query that change item input
Hi,
I have an application with a region that displays data from a database through a dblink in which the query is dependent on a value input into a couple of items in the application.
Here is the SQL:
SELECT
FROM
rem_rp_tract@DBLINK_WPC29_G6CEFMP1.NWO.USACE.ARMY.MIL "REM_RP_TRACT"
WHERE
"REM_RP_TRACT"."PROJ_ID" = upper(:P2_PROJECT_CODE)
AND "REM_RP_TRACT"."TRACT_NO" = upper(:P2_TRACTNO)
The P2_PROJECT_CODE and P2_TRACTNO values correspond to locations in a map layer in oracle spatial and data in the dblink indicated in the SQL. The problem is that the TRACT is designated with a dash (J-840) in oracle spatial and in the database it is designated without a dash (J840). Therefore, if I input Tract Number J-840 into the item have developed the app and map to zoom to the tract but no data is displayed because the database does not recognize the value. On the other hand, if I input J840 the data from the database will displayed but oracle spatial doesn't recognize it so the map does not zoom to the tract.
What I would like to do is be able to input the value with the dash (J-840) but change the SQL above so that it queries J840, i.e. all values without a dash. Is this possible?
Any help is greatly appreciated,
KirkTry This
SELECT *
FROM rem_rp_tract@DBLINK_WPC29_G6CEFMP1.NWO.USACE.ARMY.MIL "REM_RP_TRACT"
WHERE "REM_RP_TRACT"."PROJ_ID" = upper(:P2_PROJECT_CODE)
AND "REM_RP_TRACT"."TRACT_NO" = REPLACE(upper(:P2_TRACTNO),'-')
SQL> var myvar varchar2(20);
SQL> exec :myvar:='J-840' ;
PL/SQL procedure successfully completed.
SQL> select :myvar , replace(:myvar,'-') from dual ;
:MYVAR REPLACE(:MYVAR,'-')
J-840 J840Replace the - in the string to null.
SS -
Coul anyone help me with a sql query that involves a jcombobox?
HI all
i'm writing this program in wich i want to query a table in a ms access db. My os is win2000 and i use access2000.
so i have a list of categories in a jcombobox.When one of the categories is selected i have to display the corresponding product for that category in a jtext area.
I wrote the code.But i keep getting an erro at run time when i selct an item from the combobox wich is :
SQL Error: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Invalid descriptor index 20 S1002
here's my code:
boxcategories.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JComboBox cb = (JComboBox)e.getSource();
String mySelection = (String)cb.getSelectedItem();
//connecting to the data base
Connection connec;
String data = "jdbc:odbc:MyDB";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connec = DriverManager.getConnection(
data , "", "");
PreparedStatement ps = connec.prepareStatement(" SELECT Category from products"+
" WHERE Category =?");
ps.setString(1,mySelection );
ResultSet rs = ps.executeQuery();
if (rs.next() ) {
products.append(rs.getString(1)+"\t"+
rs.getString(2)+"\t\t"+
"$" rs.getString(4) "\t ");
} catch (SQLException s) {
System.out.println("SQL Error: " + s.toString() + " "
+ s.getErrorCode() + " " + s.getSQLState());
} catch (Exception x) {
System.out.println("Error: " + x.toString()
+ x.getMessage());
so what do u think i should do
Franckhi
i'm having a problem with this query.When i select a categoryfrom
the combobox,i only get one corresponding product displayed in the jtextarea
I tryed everythin but i cant get this code to work correctly.
i want that when i select a category from the combobox that the corresponding product of wich the in stock quantity is >20 to be displayed
in one jtext area and thos who's in stock quantity is < in another jtext area
What should i do?
here's my code
boxcategories.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JComboBox cb = (JComboBox)e.getSource();
String mySelection = (String)cb.getSelectedItem();
//connecting to the data base
Connection connec;
String data = "jdbc:odbc:MyDB";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connec = DriverManager.getConnection(
data , "", "");
PreparedStatement ps = connec.prepareStatement(" SELECT Category from products"+
" WHERE Category =?");
ps.setString(1,mySelection );
ResultSet rs = ps.executeQuery();
if (rs.next() ) {
products.setText((rs.getInt(1)+"\t"+
rs.getString(2)+"\t\t"+
"$" rs.getFloat(4) "\t " rs.getInt(5) "\n" );
if(rs.getInt(5) < 20)
products1.setText(rs.getInt(1)+"\t"+
rs.getString(2)+"\t\t"+
"$" rs.getFloat(4) "\t " + rs.getInt(5) +"\n" );
else
produitdescription.setText("");produitdescription1.setText("");
} catch (SQLException s) {
System.out.println("SQL Error: " + s.toString() + " "
+ s.getErrorCode() + " " + s.getSQLState());
} catch (Exception x) {
System.out.println("Error: " + x.toString()
+ x.getMessage());
when i selct a category i get this runtime error at the same time the product is displayed
SQL Error: java.sql.SQLException: No data found 0 null
what should i do
FRanck -
When I plug my phone in it says it needs to update to the new software so I try to update it and it just says backing up. Someone please help me.
Snafujafo wrote:
Dear ED3K:
First: I hope you don't work for Apple as you have some poor communication skills in assistance. That said, I would never in a million years pay you 45 dollars to help me. I think I would sleep with Satan first!!
No one here works for Apple. This is a user-to-user technical support forum. Everyone here is a volunteer. You tend to get from this forum what you bring to it. If you come in ranting and raving and saying you're going to throw your iPhone out the window and that Apple is mean, people are not likely to respond to you with sweetness and light and puppies and kittens.
If you really want help, I'd suggest you take a deep breath and then start a new thread in which you explain the problems you're having, the steps you've taken to resolve the problems, any error messages you've gotten. Stick to the facts. Check the attitude and emotion at the door. People will do their best to help you.
Best of luck. -
How do we tune a query that takes more time for the first time?
Hi,
First time it takes 20 secs and subsequent times 2 secs.
Let me know if you need more info
ThanksFollowing are the parameters set at the DB level.
.__db_cache_size=2214592512
.__java_pool_size=16777216
.__large_pool_size=16777216
.__shared_pool_size=1543503872
.__streams_pool_size=33554432
*._optimizer_cost_based_transformation='off'
*._smu_debug_mode=4
*.compatible='10.2.0.1.0'
*.cursor_sharing='SIMILAR'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.job_queue_processes=10
*.open_cursors=5000
*.optimizer_mode='ALL_ROWS'
*.pga_aggregate_target=1277165568
*.processes=250
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=1000
*.sga_target=3833593856
*.undo_management='AUTO'
*.undo_tablespace='UBPTAB_UNDO'
Execution Plan
Plan hash value: 2107556093
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 45157 | 29M| | 9094 (1)| 00:01
:50 |
| 1 | SORT ORDER BY | | 45157 | 29M| 78M| 9094 (1)| 00:01
:50 |
|* 2 | TABLE ACCESS FULL| <tname>| 45157 | 29M| | 2564 (2)| 00:00
:31 |
Following are result from dba_tab_statistics.
NUM_ROWS BLOCKS EMPTY_BLOCKS AVG_CACHE_HIT_RATIO AVG_ROW_LEN
112704 11520 768 685
AVG_SPACE_FREELIST_BLOCKS NUM_FREELIST_BLOCKS
0 0
Follwing was the time it has taken to generate the explain plan report after issuing the below command.
set autotrace traceonly
Elapsed: 00:00:15.49
Following is the statistics
Statistics
0 recursive calls
0 db block gets
11380 consistent gets
0 physical reads
0 redo size
8823636 bytes sent via SQL*Net to client
37731 bytes received via SQL*Net from client
3019 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
45267 rows processed
Pl let us know how to tune the same.
Thank you all for the help
Maybe you are looking for
-
Manage Item Cost per Warehouse
Previous posts have confirmed that it is not possible to change the Manage Item Cost per Warehouse option once any inventory transactions have been posted. One entry posted in Feb 2010 (below) even offered a link to other "Irreversible Ticks" (altho
-
My Ipod Touch 3g has a stuck slider, can anyone help?
About three days ago my ipod 3g suddenly died on me after rebooting and restoring to factory settings it finally came back alive and was able to sync my music, however the slider is now not wanting to work. No matter how many times I try to slide it
-
How to Backup & Partition Internal Hard Drive
I have a macbook pro 2.4ghz. I need to partition my hard drive to have a separate volume for photoshop scratch disk. How do I actually back up the drive prior to the reformatting? Do I create a bootable clone to restore the main volume. Specific step
-
Reg : adobe in web dynpro
hi , I am working on Adobe Online Interactive Form using webdynpro for ABAP. Steps followed for development: In WD I have created a service call and added the bapi to create sale order. Mapped the context from component controller to view controll
-
My credit card is ok on my account
My credit card is ok on my account my bank told me your service ejecting my credit card don't know why .Bank is saying iys on your end my card will be good till end of the month .Plus I have 8.75$ in my credit why you not using it for paymend rigt n