SQL Select and Hints
Hello,
i have the following SQL-Statement:
SELECT /*+ PARALLEL(mytable,16*/ COUNT(*)
FROM mytable;
Does the database use ALWAYS 16 cores (of course, if 16 cores are free) - even if the cbo (cost based optimizer ) "thinks" that this makes no sense? Or CAN the cbo use 16 cores with this sql-statement? Or if the cbo "thinks" the server has more cores as in the hint-stament, the cbo gives more cores.
Many thanks
Best regards
Heidi
Heidi Weber wrote:
Hello,
i have the following SQL-Statement:
SELECT /*+ PARALLEL(mytable,16*/ COUNT(*)
FROM mytable;
Does the database use ALWAYS 16 cores (of course, if 16 cores are free) - even if the cbo (cost based optimizer ) "thinks" that this makes no sense? Or CAN the cbo use 16 cores with this sql-statement? Or if the cbo "thinks" the server has more cores as in the hint-stament, the cbo gives more cores.
Many thanks
Best regards
HeidiYour query is missing a bracket from the hint. ;)
Looking at it one way, if I were to hint to you that it's a good idea to go jump off a cliff, would you do it? Answer: You'd look to see what the possibility of surviving is and if the chances were 100% survival (and you didn't have a fear of heights) you'd do it.
Likewise Oracle will look at a hint and if it's not going to break the query or conflict with something else that is required, it will do it, but if for some reason it can't then it won't. So if you don't have 16 cores and you're telling it to use 16, then it won't do it. There are obviously various internal rules and formula that the CBO uses when determining the best execution plan, so the hint has to be looked at in the context of the whole query. In the simple example you've given, there's no reason why it shouldn't comply with the hint.
Similar Messages
-
I have a simple SELECT statement in a Stored Proc that
queries 2 tables in
SQL Server 2000 using a join. My problem is I want to return
values based on
the outcome of the query eg. if a row is returned then return
1, or return 2
if no rows are found. I have tried various ways to implement
this and they
always work fine in Query Analyser but in Dreamweaver MX2004
either return
no return values ( or at least they are not displayed on my
page ) or the
return values are inconsistent. I am using a DW Command.
I know this is DW and not my code as Query Analyser produces
the correct
values every time. Can anyone tell me what code I can use
that is DW
friendly please.
Thanks.I read your note with a great degree of sympathy but no
solutions. I was having the same trouble with access tables after 4
years of trouble free connections. It may not be relevant but the
solutions for my problem was a Server software SP release. Details
are:
Following the avalanche of hints and tips I am pleased to
report that there is a problem with Dreamweaver MX and MX2004 when
connecting to Access databases running on Windows Server 2003 SP1.
Whilst it is covered in the knowledge base I note that others in
the forum are having similar difficulties with Sequel connections
and unable to retrieve failures.
There is a "fix" - SP2DBFix1.0.2.mxp - for my problem and I
cannot be alone in experiencing this.
And just in case anyone from Adobe is reading this, you
should have written to all your registered and paid up members
informing us of this problem when WS2003 SP1 was released!
Hope this helps. -
Can sql aggregate functions be added to an interface select clause and from clause.
I want to have a datasource where one of the columns is an aggregate such as a count, which would need the ability to indicate a from clause function group by, or having by. In the Designer Diagram tab for the interface, it seems you can only apply sql functions to where clause joins or filters.
I want to have a query such as follows as my datasource
select columnA, count(*) as thecount
from table x
group by columnA
order by thecount asc
and ultimately
select columnA, thecount
from (select columnA, count(*) as thecount
from table x
group by columnA
order by thecount asc)
where rownum <1001
Can this be done in the ODI Designer, without creating a physical custom view on the database?Hi lpantuso,
Aggregate functions are added by ODI automatically. In this case you would want mappings like this:
TARGET_COL_1: columnA
TARGET_COL_2: count(*)
ODI will generate something like this:
select
columnA,
count(*)
from MY_TABLE MY_TABLE
where
(1=1)
Group By MY_TABLE.columnA
The subselect, however, isn't handled out of the box. In general ODI isn't quite as friendly with ordering clauses since order by is not relational. (Sets aren't ordered.) To get only the first 1000 columnA values, you'll probably need to create a view or break it into 2 separate interfaces.
Regards,
Matt -
Pl sql join and selecting columns from join."t"."c": invalid at debug time
I noticed the error at cc.Country that is shown because cc is not yet there at compile time (got that
from searching this forum).
Isnt that a bit weak of oracle sql developer that it doesnt compile from the outside to the inside /core but
rather form top to bottom?
Am I right with my conclusion? If so, how to do it otherwise i.e. specifying that cc.country is
a column from countrycodes joined with table6 ?
SELECT DISTINCT 0,
2,
SUBSTR('metable', 0, 1) || '_ABC',
'ABC_' || 'metable',
'ABC ' ||cc.Country ,
'+'
FROM table6
LEFT JOIN COUNTRYCODE cc
ON cc.Code = metable
WHERE metable IS NOT NULL
AND metable <> ''metalray wrote:
hi Boneist
thanks for your reply
its in a plsql procedure (10g). well as you see cc is the alias
of the table COUNTRYCODE. which does exists. the error is at 'ABC ' ||cc.Country'
telling me"PL/SQL: ORA-01747: invalid user.table.column,..."
when I put COUNTRYCODE next to table6 in the FROM it works but thats not what I want
since I want to join both tables not just select from both.Can you give us your exact code and exact error message.
I'm not finding any problem with using alias names in the query..
SQL> select d.dname
2 ,'EMPNAME : '||e.ename
3 from dept d LEFT JOIN emp e ON e.deptno = d.deptno;
DNAME 'EMPNAME:'||E.ENAME
RESEARCH EMPNAME : SMITH
SALES EMPNAME : ALLEN
SALES EMPNAME : WARD
RESEARCH EMPNAME : JONES
SALES EMPNAME : MARTIN
SALES EMPNAME : BLAKE
ACCOUNTING EMPNAME : CLARK
RESEARCH EMPNAME : SCOTT
ACCOUNTING EMPNAME : KING
SALES EMPNAME : TURNER
RESEARCH EMPNAME : ADAMS
SALES EMPNAME : JAMES
RESEARCH EMPNAME : FORD
ACCOUNTING EMPNAME : MILLER
OPERATIONS EMPNAME :
15 rows selected.
SQL> -
Getting List of SQL server and on selection of server get List of Databases using SMO
Hi,
I need to have functionality where I need to populate List of available SQL servers from local network, and when i select SQL server from list, get the list of Databases from that Server.
For this i referenced SQL SMO Dll's and placed two drop down, one lists Server names, and one lists Database names.
Dlls refered are:
Microsoft.SqlServer.ConnectionInfo.dll
Microsoft.SqlServer.Management.Sdk.Sfc.dll
Microsoft.SqlServer.Smo.dll
Microsoft.SqlServer.SqlClrProvider.dll
Microsoft.SqlServer.SqlEnum.dll
Above DLL's i have copied from SQL server SQL server 2008 installed location
C:\Program Files\Microsoft SQL Server\110\SDK\Assemblies
DLL version : 11.0.3000.0
Code i have used is:
private void MainForm_Load(object sender,
EventArgs e)
DataTable dataTable = SmoApplication.EnumAvailableSqlServers(false);
cmbServers.ValueMember = "Name";
cmbServers.DataSource = dataTable;
//Now, load Databases on selection of Server combo box.
private void cmbServers_SelectedIndexChanged(object sender,
EventArgs e)
cmbDatabases.Items.Clear();
if (cmbServers.SelectedIndex != -1)
string serverName = cmbServers.SelectedValue.ToString();
Server server = new Server(serverName);
try
foreach (Database database in server.Databases)
cmbDatabases.Items.Add(database.Name);
catch (Exception ex)
string exception = ex.Message;
It works where SQL server is installed, but in systems where no SQL server is installed, it is not working, it is not returning list of SQL server and so database list.
Query is> can you please help me in this regard, what i am missing here, do i need to install any client component to use this?, or anything else what i need to do to make this functionality work.
Thanks,
HemalThanks Michael for replying.
I have gone through the reply, and the link on how to get the SMO library installed.
"To install the Client Tooks SDK without installing SQL Server, install Shared Management Objects from the SQL Server feature pack.
If you want to ensure that SQL Server Management Objects is installed on a computer that will run your application, you can use the Shared Management Objects .msi in the SQL Server feature pack."
I have few questions on "Shared Management Objects .msi"
Where do i get "Shared Management Objects .msi".
only installing this msi will install SMO?.
Can i ship this msi with my application installer?
do i need to install x86 on x86 system and x64 version of msi in x64 system, or x86 can work fine with both, my application
is x86 only.
Thanks,
Hemal -
I have 2 tables
Table Parent_child_table:
ID | Parent_id | Name
1 | NULL | Kitchen
2 | 1 | Freezer
3 | NULL | Garden
4 | 3 | Grass
Table Products:
ID | parent_child_table_ID | Price | Comment
1 | 2 | 111 | aaaa
2 | 4 | 12 | vv
I want to select Name from parent table where selected child ID are in PRODUCT table.....
The result would like:
|NAME|
|Kitchen
|Garden
Can someone help with this SQL SELECT ?Raivis wrote:
I have 2 tables
Table Parent_child_table:
ID | Parent_id | Name
1 | NULL | Kitchen
2 | 1 | Freezer
3 | NULL | Garden
4 | 3 | Grass
Table Products:
ID | parent_child_table_ID | Price | Comment
1 | 2 | 111 | aaaa
2 | 4 | 12 | vv
I want to select Name from parent table where selected child ID are in PRODUCT table.....
The result would like:
|NAME|
|Kitchen
|Garden
Can someone help with this SQL SELECT ?A guess
select
p.name
from Parent_child_table p
where p.parent_id is null
and exists
select
null
from Parent_child_table p1, products p2
where p1.id = p2. parent_child_table_id
and p1.parent_id = p.id
)The reason it's a guess is because you've really done nothing to outline WHY you should get the results you say you would like. The more time you spend creating a clear question, the less time you'll have to spend weeding through useless answers.
Cheers, -
Lookup by SQL select in ODS tables and source package
Hi all
I load FI data in ODS and need some extra info from older ODS records.
In my Update rule for target InfoObject I created 2 SQL selects on Active Data and New data tables of ODS. Selects worked fine while testing them as separate program, but I got no data while data load.
I guess, the data I need was in the same data package during data load. So I assume, besides Active/New data selects, I need to check data on SOURCE_PACKAGE. Is it possible on update rule level of InfoObject? Could you please, provide me some ABAP example?
thanx in advance, points will be awarded.SELECT in field routine:
==========================================================
DATA src_doc_no(10) TYPE c.
DATA src_item_num(3) TYPE c.
DATA src_year(5) TYPE c.
DATA src_doc_typ(2) TYPE c.
if ( COMM_STRUCTURE-AC_DOC_TYP = 'DD' or COMM_STRUCTURE-AC_DOC_TYP =
'LD' ) and STRLEN( COMM_STRUCTURE-REF_KEY3 ) = 17.
CONCATENATE COMM_STRUCTURE-REF_KEY3+0(4) '%' INTO src_year.
src_item_num = COMM_STRUCTURE-REF_KEY3+15(3).
src_doc_no = COMM_STRUCTURE-REF_KEY3+4(10).
select from NEW data of ODS:
SELECT AC_DOC_TYP into src_doc_typ
FROM /BI0/AFIAR_O0340
WHERE COMP_CODE = COMM_STRUCTURE-COMP_CODE
AND DEBITOR = COMM_STRUCTURE-DEBITOR
AND FISCVARNT = COMM_STRUCTURE-FISCVARNT
AND AC_DOC_NO = src_doc_no
AND ITEM_NUM = src_item_num
AND FISCPER like src_year.
endselect.
if src_doc_typ = ''.
select from ACTIVE data of ODS:
SELECT AC_DOC_TYP into src_doc_typ
FROM /BI0/AFIAR_O0300
WHERE COMP_CODE = COMM_STRUCTURE-COMP_CODE
AND DEBITOR = COMM_STRUCTURE-DEBITOR
AND FISCVARNT = COMM_STRUCTURE-FISCVARNT
AND AC_DOC_NO = src_doc_no
AND ITEM_NUM = src_item_num
AND FISCPER like src_year.
endselect.
endif.
RESULT = src_doc_typ.
endif.
============================================ -
Javascript and sql select statement
I am working in html db in the 10 g environment. I'm trying to create an "auto suggestion function" that predicts values as the user enters characters into a text field. I've gotten it to work by hard coding the values in the function, ie: states. btw: there are several external javascript files at work here.
What I want is to create a dynamic link to the database to gather, say, all names of providers at the time the page is built to use in the auto suggest format. I want to put this into a javascript routine and I'm having problems finding out how to mix the sql select statement into the javascript function.
For the states example, I'm using:
function StateSuggestions() {
this.states = [
"Alabama", "Alaska", "Arizona", "Arkansas",
"California", "Colorado", "Connecticut",..."Wyoming" ];
Can I substitute the hard coded data (states) with a sql select statement such
as:
select name from <dbtable> ???
How does this need to be "wrapped" or containerized?
Thank you. You have a great product in html db and your site is very useful. I appreciate everything you have done to assist us. Again, thank you.Hi,
You can use TRUNC with 2 arguments to get the first DATE in a month, year, quarter, week, hour, minute, ISO year, ...
SELECT TRUNC ( ADD_MONTHS ( SYSDATE
, 12
, 'MONTH'
) AS first_of_month
FROM dual
;The DATE returned will be in the same month, year, quearter, ... as the first argument.
\We convered the last day of the month in [your previous question|http://forums.oracle.com/forums/message.jspa?messageID=3942939#3942939].
At that time, I warded about using LAST_DAY as a cutoff point; TRUNC is a much better way.
For example, to find all appointment_dates in the current month next year:
SELECT *
FROM appointments
WHERE appointment_date >= TRUNC (ADD_MONTHS (SYSDATE, 12), 'MONTH')
AND appointment_date < TRUNC (ADD_MONTHS (SYSDATE, 13), 'MONTH')Note that
the first part of the WHERE clause calls for dates on or equal to the beginning of the 12th month in the future, but
the second part of the WHERE clause calls for dates before, not equal to , the beginning of the 13th month in the future. -
How to select from drop-down menu connected to SQL database and then autofill?
Hello,
I am in the process of creating a series of forms and I need some help if working out how to do the following.
I have already set up a data connection to an SQL database, and I have three fields connected: Job Number, Job Name and Customer Name.
What I want to do is have it so that the Job Number is a dropdown box, so they can select the number, and then the other two fields, Job Name and Customer Name, are autofilled to the information corresponding to the Job Number.
Is anyone able to help me do this please??
Thank you!!The 101 of database connections from LiveCycle Designer can be found in Stefan Camerons blog.
This is the right place to start.
http://forms.stefcameron.com/2006/09/18/connecting-a-form-to-a-database/
http://forms.stefcameron.com/2006/12/18/databases-inserting-updating-and-deleting-records/
http://forms.stefcameron.com/2006/09/29/selecting-specific-database-records/
http://forms.stefcameron.com/2006/10/12/displaying-all-records-from-an-odbc-data-connectio n/ -
SQL Injection and variable substitutions
Hello helpful forum, I'm trying to understand what really goes on "behind" the scenes
with the variable substitutions in order to protect from sql injections.
I'm using apex 3.0.0.00.20
The trickiest component seems to be a Report of type "pl/sql returning sql", since
multiple dynamic sql interpretations are done there.
consider the following innocent looking disaster:
DECLARE
l_out VARCHAR2(2000);
BEGIN
l_out := 'select * from test_injection t where t.name like ''%' || :NAME || '%''';
RETURN l_out;
END;
if NAME is a single quote the report will return:
failed to parse SQL query: ORA-00911: invalid character
which hints to the fact that NAME is not escaped, and you are in fact able to access db functions
as in: '||lower('S')||'
I also tried to put there a function that runs in a autonomous transaction to log its calls, and
I see that it's called five times for each request.
consider now the similar solution (notice the two single quotes):
DECLARE
l_out VARCHAR2(2000);
BEGIN
l_out := 'select * from test_injection t where t.name like ''%'' || :NAME || ''%''';
RETURN l_out;
END;
with this second example nothing of the above is possible.
So my theory (please confirm it or refute it) is that there is a first variable substitution done
at the pl/sql level (and in the second case :NAME is just a string so nothing is substituted).
Then the dynamic sql is executed and it returns the following string:
select * from test_injection t where t.name like '%' || :NAME || '%'
now another substitution is done (at an "APEX" level) and then query is finally executed to return
the rows to the report.
The tricky point seems to be that the first substitution doesn't escape the variable (hence the error
with the single quote), while the second substitution does.
Please let me know if this makes sense and what are the proper guidelines to avoid sql injection with
the different kinds of reports and components (SQL, pl/sql returning sql, processes, ...)
ThanksGiovanni,
You should build report regions like this using the second method so that all bind variables (colon followed by name) appear in the resultant varchar2 variable, l_out in your example, which will then be parsed as the report query. This addresses not only the SQL injection problem but the shared-pool friendliness problem.
Scott -
SQL Developer, SQL Server and the ampersand
Hello,
I am connected to a SQL Server database (2008) and am having difficulty getting a query to run properly in SQL Developer (3.1.07).
Simplified Example
select table_field
from table
where table_field <> 'This & That';
Expected results
table_field
Other stuff
Other stuff
Other stuff
Actual results
table_field
Other stuff
This & That
This & That
I cannot seem to get SQL Developer to recognize the & as a literal ampersand. I've tried escaping it numerous ways, but it always thinks it is a variable.
The query works exactly as expected in MS SQL Management Studio and Toad. Of course, I can just run it in one of those but I'd like to try to get this to work in SQL Developer. Suggestions?
Please let me know if I can provide further information. Thanks.Hi,
SQL Developers worksheet is designed for Oracle, but we allow you to run statements against SQL Server and other non Oracle databases.
This can lead to some quirks, like the one you experienced.
Oracles SQL*Plus uses ampersand to define substitution variables.
Oracle SQL Developer has implemented the same concept.
Unfortunately this does not make sense when running something against a non Oracle database.
As a workaround, you can run the following SQL*Plus command in SQL Developer, before your SQL Server query.
SET DEFINE OFF;
select 'hello & goodbye';
The following maybe of some help as well.
http://dermotoneill.blogspot.com/2010/11/workheet-hints.html
http://dermotoneill.blogspot.com/2010/12/sql-server-and-sybase-browsing.html
Regards,
Dermot.
SQL Developer Team. -
Performance ... normal selects and the same selects in functions
Hi there,
hope you guys can help me a little.
We use a bunch of dictionary tables to map certain values to IDs. In the "real" data tables we save the IDs instead of the values themselves.
Those tables are usually pretty small.
Normally we would join these tables into our selects, such as this:
select ...
from data_table d,
lookup_table l
where d.l_id=l.id
But we also got some functions we use to lookup these values to have simple selects:
select ..., my_function(l_id)
from data_table
Or for reverse lookup:
select ...
from data_table
where l_id=my_function(l_id)
Do you know, if smaller selects capsuled in functions are more or less performant then simply joining these tables into the big selects?
Sometimes we also use small statements on large tables (4.000.000 records) ... sometimes we use them in functions as well ...
select bla
from large_table
where id=...
Thanks for your hints,
SteffHow you did your tests?
A short conclusion of test below:
I've created 2 tables one base table and one lookup table.
Then created function to get lookup value from lookup table.
then run select to get all lookup values from base table using join and using function.
Join needed 0.01 sec, function needed at least 2.08 secs.
Then I've created an anonymous script to loop through all base values and get aproprite lookup values using function and using join and compared results using runstats.
As a result join performed at more than 2 times faster and required more than 2 times less latches.
and here is the listing
SQL> create table lookup_table (
2 lkp_id number not null,
3 lkp_val varchar2(10) not null);
Table created.
Elapsed: 00:00:00.00
SQL> alter table lookup_table add constraint lkp_pk primary key (lkp_id);
Table altered.
Elapsed: 00:00:00.00
SQL>
SQL> insert into lookup_table select rownum, substr(object_name, 1, 10) from dba_objects;
42221 rows created.
Elapsed: 00:00:00.05
SQL> create or replace function get_lkp_value (in_id number) return varchar2
2 is
3 ret lookup_table.lkp_val%TYPE;
4 begin
5 select lkp_val into ret from lookup_table where lkp_id = in_id;
6 return ret;
7 end;
8 /
Function created.
Elapsed: 00:00:00.01
SQL> create table base_table (
2 bas_id number not null,
3 bas_lkp_id number not null,
4 bas_data varchar2(1000) not null);
Table created.
Elapsed: 00:00:00.00
SQL>
SQL> insert into base_table select rownum, rownum, object_name
2 from dba_objects where rownum <= 42221;
42221 rows created.
Elapsed: 00:00:00.05
SQL> alter table base_table add constraint bas_pk primary key (bas_id);
Table altered.
Elapsed: 00:00:00.02
SQL> alter table base_table add constraint bas_lkp_fk foreign key (bas_lkp_id)
2 references lookup_table (lkp_id);
Table altered.
Elapsed: 00:00:00.01
SQL> create index bas_lkp_idx on base_table (bas_lkp_id);
Index created.
Elapsed: 00:00:00.02
SQL> exec dbms_stats.gather_table_stats(user, 'lookup_table');
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.01
SQL> exec dbms_stats.gather_table_stats(user, 'base_table');
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.02
SQL> select count(distinct lkp_val) from (
2 select bas_id, bas_data, get_lkp_value(bas_lkp_id) lkp_val
3 from base_table);
COUNT(DISTINCTLKP_VAL)
13622
Elapsed: 00:00:03.01
SQL> /
COUNT(DISTINCTLKP_VAL)
13622
Elapsed: 00:00:02.08
SQL> /
COUNT(DISTINCTLKP_VAL)
13622
Elapsed: 00:00:03.01
SQL> select count(distinct lkp_val) from (
2 select bas_id, bas_data, lkp_val
3 from base_table, lookup_table
4 where bas_lkp_id = lkp_id);
COUNT(DISTINCTLKP_VAL)
13622
Elapsed: 00:00:00.01
SQL> /
COUNT(DISTINCTLKP_VAL)
13622
Elapsed: 00:00:00.01
SQL> ed
Wrote file afiedt.buf
1 declare
2 cursor c1 (in_id in number) is
3 select bas_id, bas_data, lkp_val
4 from base_table, lookup_table
5 where bas_lkp_id = lkp_id
6 and bas_id = in_id;
7 val1 c1%ROWTYPE;
8 cursor c2 (in_id in number) is
9 select bas_id, bas_data, get_lkp_value(bas_lkp_id)
10 from base_table
11 where bas_id = in_id;
12 val2 c2%ROWTYPE;
13 begin
14 runstats_pkg.rs_start;
15 for i in 1..42220 loop
16 open c1(i);
17 fetch c1 into val1;
18 close c1;
19 end loop;
20 runstats_pkg.rs_middle;
21 for i in 1..42220 loop
22 open c2(i);
23 fetch c2 into val1;
24 close c2;
25 end loop;
26 runstats_pkg.rs_stop;
27* end;
SQL> /
Run1 ran in 390 hsecs
Run2 ran in 910 hsecs
run 1 ran in 42,86% of the time
Name Run1 Run2 Diff
LATCH.kwqit: protect wakeup ti 0 1 1
LATCH.spilled msgs queues list 0 1 1
STAT...change write time 0 1 1
LATCH.active checkpoint queue 1 3 2
LATCH.cache buffer handles 24 26 2
LATCH.process allocation 0 2 2
STAT...cleanout - number of kt 3 5 2
STAT...consistent gets - exami 253,323 253,325 2
STAT...consistent gets 253,323 253,325 2
STAT...calls to kcmgcs 3 5 2
STAT...active txn count during 3 5 2
LATCH.session timer 1 3 2
LATCH.event group latch 0 2 2
LATCH.channel handle pool latc 0 4 4
LATCH.transaction allocation 0 4 4
STAT...db block gets 520 524 4
LATCH.list of block allocation 0 4 4
LATCH.process group creation 0 4 4
LATCH.dummy allocation 0 4 4
LATCH.post/wait queue 11 16 5
LATCH.Consistent RBA 18 24 6
LATCH.mostly latch-free SCN 18 24 6
STAT...consistent changes 510 516 6
STAT...session logical reads 253,843 253,849 6
STAT...db block changes 1,020 1,026 6
LATCH.lgwr LWN SCN 18 24 6
LATCH.channel operations paren 4 12 8
LATCH.user lock 0 8 8
LATCH.simulator lru latch 13 2 -11
LATCH.sequence cache 56 71 15
LATCH.redo writing 59 82 23
LATCH.enqueues 30 60 30
STAT...hot buffers moved to he 31 0 -31
LATCH.messages 100 149 49
LATCH.cache buffers lru chain 91 33 -58
LATCH.session idle bit 230 290 60
LATCH.SQL memory manager worka 136 223 87
STAT...free buffer requested 91 4 -87
STAT...shared hash latch upgra 87 0 -87
STAT...physical reads 87 0 -87
LATCH.checkpoint queue latch 69 181 112
LATCH.session allocation 44 178 134
LATCH.redo allocation 622 819 197
LATCH.undo global data 61 263 202
LATCH.dml lock allocation 92 312 220
LATCH.row cache enqueue latch 356 580 224
LATCH.simulator hash latch 12,430 12,204 -226
LATCH.row cache objects 360 626 266
LATCH.enqueue hash chains 141 477 336
STAT...recursive cpu usage 259 596 337
STAT...Elapsed Time 392 913 521
LATCH.library cache pin alloca 402 1,100 698
LATCH.cache buffers chains 257,991 260,038 2,047
STAT...calls to get snapshot s 42,221 84,441 42,220
STAT...execute count 42,221 84,441 42,220
STAT...recursive calls 126,662 168,882 42,220
STAT...session pga memory 0 65,536 65,536
LATCH.shared pool 44,133 213,801 169,668
LATCH.library cache pin 86,473 256,185 169,712
LATCH.library cache 87,511 342,530 255,019
Run1 latches total versus runs -- difference and pct
Run1 Run2 Diff Pct
491,506 1,090,381 598,875 45.08%
PL/SQL procedure successfully completed.
Elapsed: 00:00:13.06Gints Plivna
http://www.gplivna.eu -
SQL Timeouts and Blocking Locks
SQL Timeouts and Blocking Locks
Just wanted to check in and see if anyone here has feedback on application settings, ColdFusion settings, JBOSS settings or other settings that could help to limit or remove SQL Timeouts and blocking locks on SID's.
We're using MS SQL 2000 with JBOSS and IIS5.
We've been seeing the following error in our logs that starts blocking locks in SQL:
java.sql.SQLException: [newScale] [SQLServer JDBC Drive] [SQLServer] Lock request time out period exceeded.
Once this happens, we're hosed until we remove the blocking SID in SQL. These are the connections to the application.
Any feedback would be great. Thanks!Hi
This is your exact solution:
Select a.username, a.sid, a.serial#, b.id1, c.sql_text
From v$session a, v$lock b, v$sqltext c
Where b.id1 in( Select distinct e.id1
from v$session d , v$lock e
where d.lockwait = e.kaddr ) and
a.sid = b.sid and
c.hash_value = a.sql_hash_value and
b.request =0;
Thanks
Sarju
Oracle DBA
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by I'm clueless:
Can someone give me the SQL statement to
show if there are any blocking database locks and if so - which user is locking the Database?
Thanks in Advance<HR></BLOCKQUOTE>
null -
Oracle SQL Select query takes long time than expected.
Hi,
I am facing a problem in SQL select query statement. There is a long time taken in select query from the Database.
The query is as follows.
select /*+rule */ f1.id,f1.fdn,p1.attr_name,p1.attr_value from fdnmappingtable f1,parametertable p1 where p1.id = f1.id and ((f1.object_type ='ne_sub_type.780' )) and ( (f1.id in(select id from fdnmappingtable where fdn like '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#%')))order by f1.id asc
This query is taking more than 4 seconds to get the results in a system where the DB is running for more than 1 month.
The same query is taking very few milliseconds (50-100ms) in a system where the DB is freshly installed and the data in the tables are same in both the systems.
Kindly advice what is going wrong??
Regards,
PurushothamSQL> @/alcatel/omc1/data/query.sql
2 ;
9 rows selected.
Execution Plan
Plan hash value: 3745571015
| Id | Operation | Name |
| 0 | SELECT STATEMENT | |
| 1 | SORT ORDER BY | |
| 2 | NESTED LOOPS | |
| 3 | NESTED LOOPS | |
| 4 | TABLE ACCESS FULL | PARAMETERTABLE |
|* 5 | TABLE ACCESS BY INDEX ROWID| FDNMAPPINGTABLE |
|* 6 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
|* 7 | TABLE ACCESS BY INDEX ROWID | FDNMAPPINGTABLE |
|* 8 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
Predicate Information (identified by operation id):
5 - filter("F1"."OBJECT_TYPE"='ne_sub_type.780')
6 - access("P1"."ID"="F1"."ID")
7 - filter("FDN" LIKE '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#
8 - access("F1"."ID"="ID")
Note
- rule based optimizer used (consider using cbo)
Statistics
0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
0 bytes sent via SQL*Net to client
0 bytes received via SQL*Net from client
0 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
9 rows processed
SQL> -
Performance between SQL Statement and Dynamic SQL
Select emp_id
into id_val
from emp
where emp_id = 100
EXECUTE IMMEDIATE
'Select '|| t_emp_id ||
'from emp '
'where emp_id = 100'
into id_valWill there be more impact in performance while using Dynamic SQL?CP wrote:
Will there be more impact in performance while using Dynamic SQL?All SQLs are parsed and executed as SQL cursors.
The 2 SQLs (dynamic and static) results in the exact same SQL cursor. So both methods will use an identical cursor. There are therefore no performance differences ito of how fast that SQL cursor will be.
If an identical SQL cursor is not found (a soft parse), the SQL engine needs to compile the SQL source code supplied, into a SQL cursor (a hard parse).
Hard parsing burns a lot of CPU cycles. Soft parsing burns less CPU cycles and is therefore better. However, no parsing at all is the best.
To explain: if the code creates a cursor (e.g. INSERT INTO tab VALUES( :1, :2, :3 ) for inserting data), it can do it as follows:
while More Data Found loop
parse INSERT cursor
bind variables to INSERT cursor
execute INSERT cursor
close INSERT cursor
end loopIf that INSERT cursor does not yet exists, it will be hard parsed and a cursor created. Each subsequent loop iteration will result in a soft parse.
However, the code will be far more optimal as follows:
parse INSERT cursor
while More Data Found loop
bind variables to INSERT cursor
execute INSERT cursor
end loop
close INSERT cursorWith this approach the cursor is parsed (hard or soft), once only. The cursor handle is then used again and again. And when the application is done inserting data, the cursor handle is released.
With dynamic SQL in PL/SQL, you cannot really follow the optimal approach - unless you use DBMS_SQL (a complex cursor interface). With static SQL, the PL/SQL's optimiser can kick in and it can optimise its access to the cursors your code create and minimise parsing all together.
This is however not the only consideration when using dynamic SQL. Dynamic SQL makes coding a lot more complex. The SQL code can now only be checked at execution time and not at development time. There is the issue of creating shareable SQL cursors using bind variables. There is the risk of SQL injection. Etc.
So dynamic SQL is seldom a good idea. And IMO, the vast majority of people that post problems here relating to dynamic SQL, are using dynamic SQL unnecessary. For no justified and logical reasons. Creating unstable code, insecure code and non-performing code.
Maybe you are looking for
-
Ipod shuffle gen 4 wont show up on itunes
I just bought the suffle 4 gen , when i plug it into my MAC itunes wont pick it up!!! how do i fix this ... i have restarted my comp i even plugged in my iphone and it picks it up! what is the deal??
-
I have subscribed to 19 blogs as live bookmarks. A couple of months ago, one of the blogs started not refreshing the list of posts. Now a second blog no longer refreshes. I have tried the "Reload Live Bookmark" option (both from the live book mark dr
-
I have gamecenter live and for some reason on the Apple TV app it won't connect. It allows me to see what games are playing but when I try to watch a game it says that I must wither login or restore, if I hit restore it says I can't connect to iTunes
-
Vendor created in SRM and sent to MM
Hi, All procurement (only indirect procurement) will be managed in SRM 7 with ECS. In order to manage vendor request creation with workflow in the portal, we plan to manage all vendor creation in SRM and to replicate it to MM. These vendors will be p
-
Hi With T Code MM02 the screen is displayed which has Field Material . In This i want to search all the material Like Raw Material , Semi Finished and finished .When i press F4 to search material , the next screen is Initial Class First fiels is of C