Consistent gets and buffer gets
Hi,
what is the difference between Consistent gets and buffer gets ?
Many thanks before.
plz the documentation is your friend. You can search from tahiti.oracle.com or 10.2 (or your version) docu library.
Similar Messages
-
How to calculate #Buffer Gets # Exec Buffer Gets/Exec
Hi,
How to calculate #Buffer Gets,# Execution time,Buffer Gets/Exec for a sql query?Nirmal
You can find out these statistics from two places
1) using SQL_TRACE (10046 trace) and then TKPROF (or Autotrace in SQL*Plus)
2) or looking at V$SQL which records the cost assigned to each SQL statement since the statement was first cached.
If you use Statspack or AWR, you can see the difference between two points in time, so you can calculate the cost for a period of time.
See Using SQL_Trace and TKPROF
http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96533/sqltrace.htm#1018
and Using Statspack
http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96533/statspac.htm#34837
(see the 10g documentation equivalents if necessary).
Remember, ratios (eg gets/exec) aren't always very helpful. You're best off concentrating on those operations which take longest (ie where there is the most potential to save time). See (eg) www.hotsos.com, www.oraperf.com, and others to identify effective performance methodologies.
HTH
Regards Nigel -
What causes BUFFER GETS and PHYSICAL READS in INSERT operation to be high?
Hi All,
Am performing a huge number of INSERTs to a newly installed Oracle XE 10.2.0.1.0 on Windows. There is no SELECT statement running, but just INSERTs one after the other of 550,000 in count. When I monitor the SESSION I/O from Home > Administration > Database Monitor > Sessions, I see the following stats:
BUFFER GETS = 1,550,560
CONSISTENT GETS = 512,036
PHYSICAL READS = 3,834
BLOCK CHANGES = 1,034,232
The presence of 2 stats confuses. Though the operation is just INSERT in database for this session, why should there be BUFFER GETS of this magnitude and why should there by PHYSICAL READS. Aren't these parameters for read operations? The BLOCK CHANGES value is clear as there are huge writes and the writes change these many blocks. Can any kind soul explain me what causes there parameters to show high value?
The total columns in the display table are as follows (from the link mentioned above)
1. Status
2. SID
3. Database Users
4. Command
5. Time
6. Block Gets
7. Consistent Gets
8. Physical Reads
9. Block Changes
10. Consistent Changes
What does CONSISTENT GETS and CONSISTENT CHANGES mean in a typical INSERT operation? And does someone know which all tables are involved in getting these values?
Thank,
...Flake wrote:
Hans, gracias.
The table just have 2 columns, both of which are varchar2 (500). No constraints, no indexes, neither foreign key references are in place. The total size of RAM in system is 1GB, and yes, there are other GUI's going on like Firefox browser, notepad and command terminals.
But, what does these other applications have to do with Oracle BUFFER GETS, PHYSICAL READS etc.? Awaiting your reply.Total RAM is 1GB. If you let XE decide how much RAM is to be allocated to buffers, on startup that needs to be shared with any/all other applications. Let's say that leaves us with, say 400M for the SGA + PGA.
PGA is used for internal stuff, such as sorting, which is also used in determing the layout of secondary facets such as indexes and uniqueness. Total PGA usage varies in size based on the number of connections and required operations.
And then there's the SGA. That needs to cover the space requirement for the data dictionary, any/all stored procedures and SQL statements being run, user security and so on. As well as the buffer blocks which represent the tablespace of the database. Since it is rare that the entire tablespace will fit into memory, stuff needs to be swapped in and out.
So - put too much space pressure on the poor operating system before starting the database, and the SGA may be squeezed. Put that space pressure on the system and you may enbd up with swapping or paging.
This is one of the reasons Oracle professionals will argue for dedicated machines to handle Oracle software. -
Hello !
Does the counter of event buffer gets include the logical reads ?
Does the mertic buffer gets include the event of reading from undo buffer ?
Thanks and regards,
Pavel
Edited by: Pavel on Jun 27, 2012 3:08 AM
Edited by: Pavel on Jun 27, 2012 3:35 AM
Edited by: Pavel on Jun 27, 2012 4:13 AMHi,
buffer gets = number of times a block was requested from buffer cache. A buffer get always request in a logical read. Depending on whether or not a copy of the block is available in the buffer cache, a logical read may or may not involve a physical read. So "buffer gets" and "logical reads" are basically synonyms and are often used interchangeably.
Oracle doesn't have a special "undo buffer". Undo blocks are stored in rollback segments in UNDO tablespace, and are managed in the same way data blocks are (they're even protected by redo). If a consistent get requires reading from UNDO tablespace, then statistics counters will show that, i.e. there will be one more consistent get in your autotrace.
For more information and some examples, see a thread at askTom:
http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:549546900346542976
Best regards,
Nikolay -
Consistent gets and db block gets
Hi...
I wanted to know the difference between consistent gets and db block gets in v$sess_io.I have read that consistent gets is the blocks in consistent mode..so here what does consistent mode means????
Thanks in Advance,
AnandHere's the complete text of the answer I originally wrote nearly 5 years ago on the Oracle-L mailing list:
A 'db block get' is a current mode get. That is, it's the most up-to-date copy of the data in that block, as it is right now, or currently. There can only be one current copy of a block in the buffer cache at any time. Db block gets generally are used when DML changes data in the database. In that case, row-level locks are implicitly taken on the updated rows. There is also at least one well-known case where a select statement does a db block get, and does not take a lock. That is, when it does a full table scan or fast full index scan, Oracle will read the segment header in current mode (multiple times, the number varies based on Oracle version).
A 'consistent get' is when Oracle gets the data in a block which is consistent with a given point in time, or SCN. The consistent get is at the heart of Oracle's read consistency mechanism. When blocks are fetched in order to satisfy a query result set, they are fetched in consistent mode. If no block in the buffer cache is consistent to the correct point in time, Oracle will (attempt to) reconstruct that block using the information in the rollback segments. If it fails to do so, that's when a query errors out with the much dreaded, much feared, and much misunderstood ORA-1555 "snapshot too old".
As to latching, and how it relates, well, consider that the block buffers are in the SGA, which is shared memory. To avoid corruption, latches are used to serialize access to many linked lists and data structures that point to the buffers as well as the buffers themselves. It is safe to say that each consistent get introduces serialization to the system, and by tuning SQL to use more efficient access paths, you can get the same answer to the same query but do less consistent gets. This not only consumes less CPU, it also can significantly reduce latching which reduces serialization and makes your system more scalable.
Well, that turned out longer than I planned. If you're still reading, I hope it helped!
Hope that helps,
-Mark
PS The original question asked about latching as well, which explains the reason for the third paragraph.
Edited by: mbobak on Sep 2, 2008 11:07 PM -
Most buffer gets and disk reads on table "CRMD_BRELVONAI"
hello friends,
we have to much buffer gets and disk reads on this table. se11 says:
2 indexes on this table:
first:
OBJKEY_A -
Index CRMD_BRELVONAI~1 exist on DB ORACLE
second:
OBJKEY_B-
Index not exist on DB ORACLE
Has anbody created the second index and good experience? OSS has no information.
thanks,
christophHo Christioph,
If you double click on secondary index OBJECT_B you will get to index screen. Note that secondary index OBJECT_B as been set to <b>No database index</b>.
For your information, here is a copy of the related documentation.
Create the index in the database (selection)
Whether an index improves or worsens performance often depends on the database system. You can therefore set whether an index defined in the ABAP Dictionary should be created in the database.
This makes it easier to install a platform-specific customer system.
You can set this option as follows:
<b>Index in all database systems:</b> The index is always created in the database.
<b>In selected database systems:</b> The index is created depending on the database system used. In this option, you must specify the databases in which the indexes are to be created. You can do this either on an inclusive (list of systems on which it should be created) or an exclusinve (list of systems on which it should not be created) basis. In either case, you can list up to four different database systems.
<b>No database index:</b> The index is not created in the database. If you set this option for an index that already exists in the database, it is deleted when you activate the table in the ABAP Dictionary.
Note: Unique indexes have an extra function, and must therefore always be created in the database. The database system prevents entries or index fields being duplicated. Since programs may rely on this database function, you cannot delete unique indexes from the database.
Hopping this answer your question.
Sincerely,
Alain Gauthier -
High Consistent Gets and memory settings
What is actually high consistent gets?
I get High Consistent Gets for certain sessions. Following are some of my parameter settings.
db_16k_cache_size = 0
db_2k_cache_size = 0
db_32k_cache_size = 0
db_4k_cache_size = 0
db_8k_cache_size = 0
db_block_size = 8192
sga_max_size = 7632M
sga_target = 7632M
shared_pool_reserved_size = 119957094
shared_pool_size = 48M
pga_aggregate_target = 1500M
Will setting AMM by configuring following parameter help Oracle to manage the memory in terms of workload and reduce CONSISTENT GETS?
Or do I need to manually configure parameter such as "db_8k_cache_size".?
memory_max_target = my SGA+PGA: 9.5G
memory_target = my SGA+PGA: 9.5G
sga_target = 0
pga_agreegate_target =0
Regards, LilyLily wrote:
What is actually high consistent gets?These are the logical IO's . If the logical IOs are high, it may mean that you have selected a lot of data which is now supposed to be given back to you. The high Logical IOs is not something that you should try to minimize using a high amount of memory since its already cached data. That sort of workaround works or would work if the physical IOs are high. If the session is doing more logical IO's check the query and the selectivity of the data and see if you can limit it further.
I get High Consistent Gets for certain sessions. Following are some of my parameter settings.
db_16k_cache_size = 0
db_2k_cache_size = 0
db_32k_cache_size = 0
db_4k_cache_size = 0
db_8k_cache_size = 0
db_block_size = 8192
sga_max_size = 7632M
sga_target = 7632M
shared_pool_reserved_size = 119957094
shared_pool_size = 48M
pga_aggregate_target = 1500M
Will setting AMM by configuring following parameter help Oracle to manage the memory in terms of workload and reduce CONSISTENT GETS?
Or do I need to manually configure parameter such as "db_8k_cache_size".?
memory_max_target = my SGA+PGA: 9.5G
memory_target = my SGA+PGA: 9.5G
sga_target = 0
pga_agreegate_target =0
As I said, instance tuning is not something that you should aim for .
Aman.... -
Need help in understanding why so many gets and I/O
Hi there,
I have a sql file somewhat similar in structure to below:
delete from table emp;-- changed to Truncate table emp;
delete from table dept;--changed to Truncate table dept;
insert into emp values() select a,b,c from temp_emp,temp_dept where temp_emp.id=temp_dept.emp_id
update emp set emp_name=(select emp_name from dept where emp.id=dept.emp_id);
commit --only at the end
the above file takes about 9-10 hrs to complete its operation. and
the values from v$sql for the statement
update emp set emp_name=(select emp_name from dept where emp.id=dept.emp_id);
are as below:
SHARABLE_MEM PERSISTENT_MEM RUNTIME_MEM SORTS LOADED_VERSIONS OPEN_VERSIONS USERS_OPENING FETCHES EXECUTIONS PX_SERVERS_EXECUTIONS END_OF_FETCH_COUNT USERS_EXECUTING LOADS FIRST_LOAD_TIME INVALIDATIONS PARSE_CALLS DISK_READS DIRECT_WRITES BUFFER_GETS APPLICATION_WAIT_TIME CONCURRENCY_WAIT_TIME CLUSTER_WAIT_TIME USER_IO_WAIT_TIME PLSQL_EXEC_TIME JAVA_EXEC_TIME ROWS_PROCESSED COMMAND_TYPE OPTIMIZER_MODE OPTIMIZER_COST OPTIMIZER_ENV OPTIMIZER_ENV_HASH_VALUE PARSING_USER_ID PARSING_SCHEMA_ID PARSING_SCHEMA_NAME KEPT_VERSIONS ADDRESS TYPE_CHK_HEAP HASH_VALUE OLD_HASH_VALUE PLAN_HASH_VALUE CHILD_NUMBER SERVICE SERVICE_HASH MODULE MODULE_HASH ACTION ACTION_HASH SERIALIZABLE_ABORTS OUTLINE_CATEGORY CPU_TIME ELAPSED_TIME OUTLINE_SID CHILD_ADDRESS SQLTYPE REMOTE OBJECT_STATUS LITERAL_HASH_VALUE LAST_LOAD_TIME IS_OBSOLETE CHILD_LATCH SQL_PROFILE PROGRAM_ID PROGRAM_LINE# EXACT_MATCHING_SIGNATURE FORCE_MATCHING_SIGNATURE LAST_ACTIVE_TIME BIND_DATA TYPECHECK_MEM
18965 8760 7880 0 1 0 0 0 2 0 2 0 2 2011-05-10/21:16:44 1 2 163270378 0 164295929 0 509739 0 3215857850 0 0 20142 6 ALL_ROWS 656 E289FB89A4E49800CE001000AEF9E3E2CFFA331056414155519421105555551545555558591555449665851D5511058555155511152552455580588055A1454A8E0950402000002000000000010000100050000002002080007D000000000002C06566001010000080830F400000E032330000000001404A8E09504646262040262320030020003020A000A5A000 4279923421 50 50 APPS 0 00000003CBE5EF50 00 1866523305 816672812 1937724149 0 SYS$USERS 0 01@</my.sql -2038272289 -265190056 0 9468268067 10420092918 00000003E8593000 6 N VALID 0 2011-05-11/10:23:45 N 5 0 0 1.57848E+19 1.57848E+19 5/12/2011 4:39 0
1) how do i re-write this legacy script? and what should be done to improve performance?
2) Should i use PL/sql to re-write it?
3) Also help in understanding why a simple update statement is doing so many buffer gets and reading , Is this Read consistency Trap as i'm not committing anywhere in between or it is actually doing so much of work.
(assume dept table has cols emp_name and emp_id also)update emp set emp_name=(select emp_name from dept where emp.id=dept.emp_id);I guess that these are masked table names ? Nobody would have emp_name in a dept table.
Can you re-format the output, using "code" tags ( [ or { }
Hemant K Chitale
Edited by: Hemant K Chitale on May 12, 2011 12:44 PM -
Good or bad to have buffer gets
Is it good to have high buffer gets?
In the manuals it seems they say it is not good ...There is not a query, application, database table or forum that can answer this question. You might see a statement that takes 10 hours to run, performs 42 billion consistent reads and 42 million disk reads...and it is running just fine. There might be a statement that takes 1 minute to run, performs 1000 consistent reads and no disk reads that is the worst performing sql in the application.
Before you decide that I am out of my mind...consider...
The first statement is an overnight batch job that performs an ETL process for the data warehouse. As long as it finishes by 7am the next morning, it does not matter how fast it runs (no one logs in to the system until 8am).
The second statement retrieves the customer account information that is used hundreds of thousands of times during the day by the sales force. I know that I would be an unhappy customer if I had to wait 1 minute every time I called in to place an order.
The only way to find the worst performing sql is to talk to the users and business, have them tell you what their important processes are and how they are impacted by response time.
There is nothing worse than spending hours tuning a sql statement that did not need to be tuned!
Regards,
Daniel Fink -
MySQL and Java - getting program to work
I am setting up mysql to run sql from a Java program on my pc at home and probably biting off more than I can chew. I get these messages when executing the java program ExecuteSQL.java:
Exception in thread "main" java.lang.NoClassDefFoundError: Test2 <wrong name: MyProjects/test2/Test2>
at java.lang.ClassLoader.defineClass0<Native Method>
at java.lang.ClassLoader.defineClass<Unknown Source>
at java.security.SecurityClassLoader.defineClass<Unknown Source>
at java.net.URLClassLoader.defineClass<Unknown Source>
at java.net.URLClassLoader.access$100<Unknown Source>
at java.net.URLClassLoader$1.run<Unknown Source>
at java.security.AccessController.ddPrivileged<Native Method>
at java.lang.ClassLoader.findClass<Unknown Source>
at java.lang.ClassLoader.loadClass<Unknown Source>
at sun.misc.Launcher$AppClassLoader.loadClass<Unknown Source>
at java.lang.ClassLoader.loadClass<Unknown Source>
at java.lang.ClassLoader.loadClassInternal<Unknown Source>
This is what I did.
I created a folder on my C: drive named MySQL.
I downloaded these two zip files form the MySQL website
* mysql-connector-java-3.0.11-stable
* mysql-4.0.18-win.zip
Installed both of these in folder MySQL.
I modified this line in the program ("ExecuteSQL" 1st pgm in chapter 17) I got from "Java Examples In a Nutshell" and compiled it into directory jwork.
String driver = "com.mysql.jdbc.driver", url = "jdbc:mysql://", user = "", password = "";
The readme file talks about putting a jar file in $JAVA_HOME/jre/lib/ext.
the word "Java_Home" (I now know) is not literally the name but represents the
name of the folder where the JDK to be used exists. So I put a copy of
mysql-connector-java-3.0.11-stable-bin.jar in folder C:\JDK14/jre/lib/ext.
Then I get a ClassNotFoundException error com.mysql.jdbc.driver.
After finding
http://forum.java.sun.com/thread.jsp?forum=31&thread=439796
and
http://forum.java.sun.com/thread.jsp?forum=31&thread=499888
and others, I copied (a second copy) the jar file to the directory where I am create my java objects.
Then I unzipped it to that directory, creating three folders that hold the unzipped objects.
I tried executing the program again. I get the messages at the top of this post.
The Manifest file is in one of the three folders unzipped to my java work directory.
In the second of the two above threads, jsalonen says:
the problem can be solved by mentioning mysql.jar in the Class-Path attribute
in the manifest of the jar file:
In this "manifest" file, there are only three lines and I added a fourth and it looks like this
(there are two, one in directory MySQL\META-INF and one in directory jwork\META-INF:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.1
Created-By: 1.4.0_01-b03 (Sun Microsystems Inc.)
Main-Class:jwork\ExecuteSQL
How do I "mention" mysql.jar in the class path attribute?
In the index.list file (in the directory with the manifest file, do I need to add anything to refer that "com.mysql.jdbc.driver" is the driver?
Do I need index.list in MySQL\META-INF ?
Thank you for your help. The program ExecuteSQL follows.
* Copyright (c) 2000 David Flanagan. All rights reserved.
* This code is from the book Java Examples in a Nutshell, 2nd Edition.
* It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied.
* You may study, use, and modify it for any non-commercial purpose.
* You may distribute it non-commercially as long as you retain this notice.
* For a commercial use license, or to purchase the book (recommended),
* visit http://www.davidflanagan.com/javaexamples2.
/** package com.davidflanagan.examples.sql; */
import java.sql.*;
import java.io.*;
* A general-purpose SQL interpreter program.
public class ExecuteSQL {
public static void main(String[] args) {
Connection conn = null; // Our JDBC connection to the database server
try {
String driver = "com.mysql.jdbc.driver", url = "jdbc:mysql://",
user = "", password = "";
// Parse all the command-line arguments
for(int n = 0; n < args.length; n++) {
if (args[n].equals("-d")) driver = args[++n];
else if (args[n].equals("-u")) user = args[++n];
else if (args[n].equals("-p")) password = args[++n];
else if (url == null) url = args[n];
else throw new IllegalArgumentException("Unknown argument.");
// The only required argument is the database URL.
if (url == null)
throw new IllegalArgumentException("No database specified");
// If the user specified the classname for the DB driver, load
// that class dynamically. This gives the driver the opportunity
// to register itself with the DriverManager.
if (driver != null) Class.forName(driver);
// Now open a connection the specified database, using the
// user-specified username and password, if any. The driver
// manager will try all of the DB drivers it knows about to try to
// parse the URL and connect to the DB server.
conn = DriverManager.getConnection(url, user, password);
// Now create the statement object we'll use to talk to the DB
Statement s = conn.createStatement();
// Get a stream to read from the console
BufferedReader in =
new BufferedReader(new InputStreamReader(System.in));
// Loop forever, reading the user's queries and executing them
while(true) {
System.out.print("sql> "); // prompt the user
System.out.flush(); // make the prompt appear now.
String sql = in.readLine(); // get a line of input from user
// Quit when the user types "quit".
if ((sql == null) || sql.equals("quit")) break;
// Ignore blank lines
if (sql.length() == 0) continue;
// Now, execute the user's line of SQL and display results.
try {
// We don't know if this is a query or some kind of
// update, so we use execute() instead of executeQuery()
// or executeUpdate() If the return value is true, it was
// a query, else an update.
boolean status = s.execute(sql);
// Some complex SQL queries can return more than one set
// of results, so loop until there are no more results
do {
if (status) { // it was a query and returns a ResultSet
ResultSet rs = s.getResultSet(); // Get results
printResultsTable(rs, System.out); // Display them
else {
// If the SQL command that was executed was some
// kind of update rather than a query, then it
// doesn't return a ResultSet. Instead, we just
// print the number of rows that were affected.
int numUpdates = s.getUpdateCount();
System.out.println("Ok. " + numUpdates +
" rows affected.");
// Now go see if there are even more results, and
// continue the results display loop if there are.
status = s.getMoreResults();
} while(status || s.getUpdateCount() != -1);
// If a SQLException is thrown, display an error message.
// Note that SQLExceptions can have a general message and a
// DB-specific message returned by getSQLState()
catch (SQLException e) {
System.err.println("SQLException: " + e.getMessage()+ ":" +
e.getSQLState());
// Each time through this loop, check to see if there were any
// warnings. Note that there can be a whole chain of warnings.
finally { // print out any warnings that occurred
SQLWarning w;
for(w=conn.getWarnings(); w != null; w=w.getNextWarning())
System.err.println("WARNING: " + w.getMessage() +
":" + w.getSQLState());
// Handle exceptions that occur during argument parsing, database
// connection setup, etc. For SQLExceptions, print the details.
catch (Exception e) {
System.err.println(e);
if (e instanceof SQLException)
System.err.println("SQL State: " +
((SQLException)e).getSQLState());
System.err.println("Usage: java ExecuteSQL [-d <driver>] " +
"[-u <user>] [-p <password>] <database URL>");
// Be sure to always close the database connection when we exit,
// whether we exit because the user types 'quit' or because of an
// exception thrown while setting things up. Closing this connection
// also implicitly closes any open statements and result sets
// associated with it.
finally {
try { conn.close(); } catch (Exception e) {}
* This method attempts to output the contents of a ResultSet in a
* textual table. It relies on the ResultSetMetaData class, but a fair
* bit of the code is simple string manipulation.
static void printResultsTable(ResultSet rs, OutputStream output)
throws SQLException
// Set up the output stream
PrintWriter out = new PrintWriter(output);
// Get some "meta data" (column names, etc.) about the results
ResultSetMetaData metadata = rs.getMetaData();
// Variables to hold important data about the table to be displayed
int numcols = metadata.getColumnCount(); // how many columns
String[] labels = new String[numcols]; // the column labels
int[] colwidths = new int[numcols]; // the width of each
int[] colpos = new int[numcols]; // start position of each
int linewidth; // total width of table
// Figure out how wide the columns are, where each one begins,
// how wide each row of the table will be, etc.
linewidth = 1; // for the initial '|'.
for(int i = 0; i < numcols; i++) { // for each column
colpos[i] = linewidth; // save its position
labels[i] = metadata.getColumnLabel(i+1); // get its label
// Get the column width. If the db doesn't report one, guess
// 30 characters. Then check the length of the label, and use
// it if it is larger than the column width
int size = metadata.getColumnDisplaySize(i+1);
if (size == -1) size = 30; // Some drivers return -1...
if (size > 500) size = 30; // Don't allow unreasonable sizes
int labelsize = labels.length();
if (labelsize > size) size = labelsize;
colwidths[i] = size + 1; // save the column the size
linewidth += colwidths[i] + 2; // increment total size
// Create a horizontal divider line we use in the table.
// Also create a blank line that is the initial value of each
// line of the table
StringBuffer divider = new StringBuffer(linewidth);
StringBuffer blankline = new StringBuffer(linewidth);
for(int i = 0; i < linewidth; i++) {
divider.insert(i, '-');
blankline.insert(i, " ");
// Put special marks in the divider line at the column positions
for(int i=0; i<numcols; i++) divider.setCharAt(colpos[i]-1,'+');
divider.setCharAt(linewidth-1, '+');
// Begin the table output with a divider line
out.println(divider);
// The next line of the table contains the column labels.
// Begin with a blank line, and put the column names and column
// divider characters "|" into it. overwrite() is defined below.
StringBuffer line = new StringBuffer(blankline.toString());
line.setCharAt(0, '|');
for(int i = 0; i < numcols; i++) {
int pos = colpos[i] + 1 + (colwidths[i]-labels[i].length())/2;
overwrite(line, pos, labels[i]);
overwrite(line, colpos[i] + colwidths[i], " |");
// Then output the line of column labels and another divider
out.println(line);
out.println(divider);
// Now, output the table data. Loop through the ResultSet, using
// the next() method to get the rows one at a time. Obtain the
// value of each column with getObject(), and output it, much as
// we did for the column labels above.
while(rs.next()) {
line = new StringBuffer(blankline.toString());
line.setCharAt(0, '|');
for(int i = 0; i < numcols; i++) {
Object value = rs.getObject(i+1);
if (value != null)
overwrite(line, colpos[i] + 1, value.toString().trim());
overwrite(line, colpos[i] + colwidths[i], " |");
out.println(line);
// Finally, end the table with one last divider line.
out.println(divider);
out.flush();
/** This utility method is used when printing the table of results */
static void overwrite(StringBuffer b, int pos, String s) {
int slen = s.length(); // string length
int blen = b.length(); // buffer length
if (pos+slen > blen) slen = blen-pos; // does it fit?
for(int i = 0; i < slen; i++) // copy string into buffer
b.setCharAt(pos+i, s.charAt(i));Don't put those JARs in the lib/ext directory. Only language extensions (e.g., packages that start with "javax") belong in there.
Learn how to set the CLASSPATH properly for starters:
http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/classpath.html
You might want to look at the JDBC tutorial, too:
http://java.sun.com/docs/books/tutorial/jdbc/
Do one thing at a time. Get the program to work, then worry about packaging it into an executable JAR. -
Hi all,
possible someone could help me on following issue:
I'm working for a software vendor and one of our customers is reporting that especially 2 of the sql statements of our application are " executed ineffective" on their database environment.
They are especially saying that "These statements are consuming a lot of CPU and doing a lot of buffer gets in relation to the number of executions."
They provided following extracts out of the statspack report.
SQL1:
SQL Statistics
~~~~~~~~~~~~~~
-> CPU and Elapsed Time are in seconds (s) for Statement Total and in
milliseconds (ms) for Per Execute
% Snap
Statement Total Per Execute Total
Buffer Gets: 322,101 16.6 .89
Disk Reads: 631 0.0 .48
Rows processed: 19,444 1.0
CPU Time(s/ms): 19 1.0
Elapsed Time(s/ms): 26 1.3
Sorts: 0 .0
Parse Calls: -2 -.0
Invalidations: 0
Version count: 1
Sharable Mem(K): 43
Executions: 19,444 SQL2:
SQL Statistics
~~~~~~~~~~~~~~
-> CPU and Elapsed Time are in seconds (s) for Statement Total and in
milliseconds (ms) for Per Execute
% Snap
Statement Total Per Execute Total
Buffer Gets: 628,517 22.9 3.26
Disk Reads: 128 0.0 .18
Rows processed: 27,492 1.0
CPU Time(s/ms): 27 1.0
Elapsed Time(s/ms): 30 1.1
Sorts: 0 .0
Parse Calls: 0 .0
Invalidations: 0
Version count: 1
Sharable Mem(K): 39
Executions: 27,492 The SQL1 is an update and SQL2 an Insert on the same table.
The accessed table has 6 indexes and a primary key column. On SQL1, the update, the where condition is reffering to the primary key column.
Both statements are using bind variables.
From my point, I would say, that the customer should provide the execution plan of both statements to verify that SQL1 is using the primary key.
As far as I understand "buffer gets" this issn't an issue because it's only saying that the data coumes out of the cache (which would be good) instead of reading the data from disk.
But I don't really see there any bottleneck.
Could you please give me some suggestions?
Many Thanks
JoergHi,
Recently we have encountered one performance issue, which is most likely caused by a sudden increase in the buffer gets per execution.
The SQL is an update statement, updating a table using a primary key (we have checked to confirm the running execution plan is using the primary key), and one field being updated is a BLOB column.
As shown in the below statistics, there is no major change in the number of executions during the every 20 minutes monitoring interval. However, the buffer gets per executions has been more than double, and the CPU time is almost doubled, hence the exec_time (elapsed time) has been doubled.
The same SQL has been running for the past four years in multiple similar databases. The database is Oracle 9.2.0.4 running on Solaris 9. For the past 300 days, the average elapsed time per execution is about 0.0093s, while the average buffer gets per execution is about 670. The update statement has been executed about 9 times per second.
The question is why there is a sudden increase in the buffer gets? The sudden increase happened twice for the past two days.
<pre>
B_TIME E_TIME EXECUTIONS_DIFF EXEC_TIME CPU_TIME BUFFER_GETS EXEC_PER_DAY
2009-11-25-12:23 2009-11-25-12:43 9363 .0081 .008 530.04 671338
2009-11-25-12:43 2009-11-25-13:03 11182 .0083 .008 538.59 799772
2009-11-25-13:03 2009-11-25-13:23 10433 .0078 .0077 474.61 761970
2009-11-25-13:23 2009-11-25-13:43 10043 .008 .0078 496.65 713581
2009-11-25-13:43 2009-11-25-14:04 8661 .0076 .0074 401.22 598169
2009-11-25-14:04 2009-11-25-14:23 8513 .0069 .0068 315.56 646329
2009-11-25-14:23 2009-11-25-14:43 10170 .007 .0068 312.28 726188
2009-11-25-14:43 2009-11-25-15:05 11873 .0072 .0069 320.17 787885
2009-11-25-15:05 2009-11-25-15:23 8633 .011 .0101 844.83 675014
2009-11-25-15:23 2009-11-25-15:44 9668 .0144 .0137 1448.51 680778
2009-11-25-15:44 2009-11-25-16:04 9671 .0163 .0156 1809.04 702163
2009-11-25-16:04 2009-11-25-16:25 10260 .0188 .0177 2107.67 711447
2009-11-25-16:25 2009-11-25-16:44 9827 .0157 .0151 1834.3 739593
2009-11-25-16:44 2009-11-25-17:05 10586 .0171 .0164 2008.25 714555
2009-11-25-17:05 2009-11-25-17:24 9625 .0189 .0181 2214.07 745829
2009-11-25-17:24 2009-11-25-17:44 9764 .016 .0154 1877.34 679782
2009-11-25-17:44 2009-11-25-18:04 8812 .0167 .0163 1989.61 652405
2009-11-26-07:24 2009-11-26-07:43 8230 .0141 .014 1614.6 614051
2009-11-26-07:43 2009-11-26-08:04 11494 .0165 .0159 1833.1 785044
2009-11-26-08:04 2009-11-26-08:24 11028 .0182 .0172 1979.61 800688
2009-11-26-08:24 2009-11-26-08:44 10533 .0154 .0149 1734.62 750248
2009-11-26-08:44 2009-11-26-09:04 9367 .018 .0168 2043.95 685274
2009-11-26-09:04 2009-11-26-09:24 10307 .0214 .0201 2552.43 729938
2009-11-26-09:24 2009-11-26-09:45 10932 .0251 .0234 3111.48 762328
2009-11-26-09:45 2009-11-26-10:05 10992 .0278 .0254 3386.41 797404
2009-11-26-10:05 2009-11-26-10:24 10179 .0289 .0269 3597.24 764088
2009-11-26-10:24 2009-11-26-10:45 10216 .032 .0286 3879.47 681592
2009-11-26-10:45 2009-11-26-11:04 10277 .0286 .0263 3539.44 799219
2009-11-26-11:20 2009-11-26-11:23 1378 .0344 .0312 4261.62 688203
2009-11-26-11:23 2009-11-26-11:36 7598 .0299 .027 3675.36 805481
2009-11-26-11:36 2009-11-26-11:43 3345 .0298 .0272 3610.28 752625
2009-11-26-11:43 2009-11-26-12:03 10383 .0295 .0278 3708.36 728158
2009-11-26-12:03 2009-11-26-12:23 10322 .0332 .03 4002.33 745669
2009-11-26-12:23 2009-11-26-12:43 11847 .0316 .0292 3899.34 852273
2009-11-26-12:43 2009-11-26-13:03 10027 .0331 .0298 4030.5 722546
2009-11-26-13:03 2009-11-26-13:23 10130 .035 .0309 4199.08 730577
2009-11-26-13:23 2009-11-26-13:43 9783 .0331 .0306 4161.3 707915
2009-11-26-13:43 2009-11-26-14:03 10460 .0322 .0291 3947.63 753748
2009-11-26-14:03 2009-11-26-14:23 9452 .0333 .0309 4143.31 678283
2009-11-26-14:23 2009-11-26-14:43 9127 .0318 .03 4051.52 659341
2009-11-26-14:51 2009-11-26-15:03 5391 .0358 .0328 4358.58 652356
2009-11-26-15:03 2009-11-26-15:16 7183 .0425 .0348 4615.42 746824
2009-11-26-15:16 2009-11-26-15:23 2921 .0417 .0373 4887.75 682092
2009-11-26-15:23 2009-11-26-15:43 9597 .0393 .0352 4603.62 679656
2009-11-26-15:43 2009-11-26-16:03 8797 .0411 .0362 4783.66 630755
2009-11-26-16:03 2009-11-26-16:23 9957 .0453 .0391 5168.28 718100
2009-11-26-16:23 2009-11-26-16:43 11209 .0436 .0369 4870.77 808395
2009-11-26-16:43 2009-11-26-17:03 10729 .0428 .0375 5119.56 766103
2009-11-26-17:03 2009-11-26-17:23 9116 .0409 .0363 4912.58 659098
</pre>
GaoYuan
Edited by: user12194561 on Nov 26, 2009 7:34 PM -
I've found this page
[http://www.billmagee.co.uk/oracle/sqltune/080_identify.html]
in which is said:
BUFFER_GETS Cumulative total of memory blocks read for this statement
so if I want to see how many blocks a query read per execution I must do ((disk_reads+buffer_gets)/executions) as suggested from the query on the same page.
select sql_text,
executions,
to_char((((disk_reads+buffer_gets)/executions) * 8192)/1048576,
'9,999,999,990.00') as total_gets_per_exec_mb,
to_char((( disk_reads /executions) * 8192)/1048576,
'9,999,999,990.00') as disk_reads_per_exec_mb,
to_char((( buffer_gets /executions) * 8192)/1048576,
'9,999,999,990.00') as buffer_gets_per_exec_mb,
parsing_user_id
from v$sqlarea
where executions > 0
order by 6 descThis is correct?
Buffer gets refers only to the block found in the buffer cache (not loaded from disk) or to the total amount of db block on which the query works (indipendetly if they are found immediately in the buffer cache or must be read from disk) ?
Hope you can help me.
Thanks
Adriano AristarcoYes, the index is appearing on the dba_indexes table, however its state is 'UNUSABLE'.
It looks impdp takes its state from origin metadata, puts into destination, and even is not trying to rebuild it.
Of course, after running ALTER INDEX REBUILD its status was changed to VALID.
So, what's the point impdp tells about its state? It can be hundreds of unusable indexes, why it's not just rebuilding it? -
Utterly and totally LOST and CONFUSED getting IE10 in Server 2012 x64 to work
I am at my wits end, I believe I posted in here before but am still having tons of problems with IE10 and Server 2012 x64. Can someone shed some light on ANY of the following:
1)Is IE10 embedded with flash player by default or not? If so what version?
2)If IE10 is embedded with flash player how do I get it to consistently work and show the flash player test movie from Adobe's site instead of a gray box (following steps on site does NOTHING to fix issue)?
2b) I have had some success simply changing the following security settings for the Internet Zone in Security:
Settings>Internet Options>Security>Internet Zone, click custom level> Active X Controls and Plugins> Script ActiveX controls marked safe for scripting: enable
Settings>Internet Options>Security>Internet Zone, click custom level> Scripting> Active Scripting: enable
on some machines the above works and I see a flash movie, other machines not.
3)What is the shockwave flash object in my add-ons for IE? Some machines have this and some don't. Was it installed by default or installed manually? I cannot install this on non working machines where it is missing as the install page from adobe (get.adobe.com/flashplayer) says there is nothing to install since IE 10 should have flash player embeded by default. (it says flash player is integrated with Windows Explorer in Windows8. You do not need to install Flash Player and the bottom of IE says an add-on for this website failed to run).
This is a NIGHTMARE process that doesn't work and is pathetic. Can someone please steer me in the direction to get this simple POS to work? Something that should work by default doesn't, and then should take no more than 10 minutes is wasting hours of my time.Hi,
The RoboHelp 10 API should work for WebHelp created with RoboHelp 9. Since the RH10 API will now support Multiscreen HTML5 (introduced with RoboHelp 10), I imagine it will work with VS 2012. But I’ve not tried that. You can try the RH10 API, but Adobe won’t support it
Alternatively: A colleague of mine created a custom C# API some time ago. That might work for you: http://www.wvanweelden.eu/blog/2012/08/03/custom-webhelp-apis
Greet,
Willam -
hey all, I have been getting the "cannot get mail" error message on my iphone5 suddenly.
ive been using iphone to check two email accounts for months now, one is gmail and not troubled. the other is mail from thunderbird and i get this error message now saying it is not responding. no settings have been changed or anything, it just suddenly stopped receiving mail on my device as of Tuesday afternoon.
Does anyone have iny ideas about why? i have yet to update to the new OS7 yet, could that be it?'The installer has insufficient privileges to modify this file C:\Program Files (x86)\Common Files\Apple\Apple Application Support\Web kit.resources\inspector\Images\Spinner Inactive Selected.gif.'
That one's consistent with disk/file damage. The first thing I'd try with that is running a disk check (chkdsk) over your C drive.
XP instructions in the following document: How to perform disk error checking in Windows XP
Vista instructions in the following document: Check your hard disk for errors
Windows 7 instructions in the following document: How to use CHKDSK (Check Disk)
Select both Automatically fix file system errors and Scan for and attempt recovery of bad sectors, or use chkdsk /r (depending on which way you decide to go about doing this). You'll almost certainly have to schedule the chkdsk to run on startup. The scan should take quite a while ... if it quits after a few minutes or seconds, something's interfering with the scan.
Does the chkdsk find/repair any damage? If so, can you get an install to go through properly afterwards? -
Sudden increase in buffer gets per executions in update statement
Hi,
Recently we have encountered one performance issue, which is most likely caused by a sudden increase in the buffer gets per execution.
The SQL is an update statement, updating a table using a primary key (we have checked to confirm the running execution plan is using the primary key), and one field being updated is a BLOB column.
As shown in the below statistics, there is no major change in the number of executions during the every 20 minutes monitoring interval. However, the buffer gets per executions has been more than double, and the CPU time is almost doubled, hence the exec_time (elapsed time) has been doubled.
The same SQL has been running for the past four years in multiple similar databases. The database is Oracle 9.2.0.4 running on Solaris 9. For the past 300 days, the average elapsed time per execution is about 0.0093s, while the average buffer gets per execution is about 670. The update statement has been executed about 9 times per second.
The question is why there is a sudden increase in the buffer gets? The sudden increase happened twice for the past two days.
<pre>
B_TIME E_TIME EXECUTIONS_DIFF EXEC_TIME CPU_TIME BUFFER_GETS EXEC_PER_DAY
2009-11-25-14:04 2009-11-25-14:23 8513 .0069 .0068 315.56 646329
2009-11-25-14:23 2009-11-25-14:43 10170 .007 .0068 312.28 726188
2009-11-25-14:43 2009-11-25-15:05 11873 .0072 .0069 320.17 787885
2009-11-25-15:05 2009-11-25-15:23 8633 .011 .0101 844.83 675014
2009-11-25-15:23 2009-11-25-15:44 9668 .0144 .0137 1448.51 680778
2009-11-25-15:44 2009-11-25-16:04 9671 .0163 .0156 1809.04 702163
2009-11-25-16:04 2009-11-25-16:25 10260 .0188 .0177 2107.67 711447
2009-11-25-16:25 2009-11-25-16:44 9827 .0157 .0151 1834.3 739593
2009-11-25-16:44 2009-11-25-17:05 10586 .0171 .0164 2008.25 714555
2009-11-26-08:04 2009-11-26-08:24 11028 .0182 .0172 1979.61 800688
2009-11-26-08:24 2009-11-26-08:44 10533 .0154 .0149 1734.62 750248
2009-11-26-08:44 2009-11-26-09:04 9367 .018 .0168 2043.95 685274
2009-11-26-09:04 2009-11-26-09:24 10307 .0214 .0201 2552.43 729938
2009-11-26-09:24 2009-11-26-09:45 10932 .0251 .0234 3111.48 762328
2009-11-26-09:45 2009-11-26-10:05 10992 .0278 .0254 3386.41 797404
2009-11-26-15:03 2009-11-26-15:16 7183 .0425 .0348 4615.42 746824
2009-11-26-15:16 2009-11-26-15:23 2921 .0417 .0373 4887.75 682092
2009-11-26-15:23 2009-11-26-15:43 9597 .0393 .0352 4603.62 679656
2009-11-26-15:43 2009-11-26-16:03 8797 .0411 .0362 4783.66 630755
2009-11-26-16:03 2009-11-26-16:23 9957 .0453 .0391 5168.28 718100
2009-11-26-16:23 2009-11-26-16:43 11209 .0436 .0369 4870.77 808395
2009-11-26-16:43 2009-11-26-17:03 10729 .0428 .0375 5119.56 766103
2009-11-26-17:03 2009-11-26-17:23 9116 .0409 .0363 4912.58 659098
</pre>
Yesterday I did a trace on one of the sessions running the update statement, and below is the tkprof output:
<pre>
call count cpu elapsed disk query current rows
Parse 76 0.03 0.00 0 0 0 0
Execute 76 4.58 5.14 0 567843 19034 76
Fetch 0 0.00 0.00 0 0 0 0
total 152 4.61 5.14 0 567843 19034 76
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 88
Rows Row Source Operation
1 UPDATE (cr=30 r=0 w=0 time=6232 us)
1 INDEX UNIQUE SCAN <PK Index Name> (cr=3 r=0 w=0 time=58 us)(object id 81122)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
Waited--------------------------------------------------------------------------------
SQL*Net message to client 152 0.00 0.00
SQL*Net message from client 152 0.00 0.22
SQL*Net more data from client 1894 0.00 0.03
SQL*Net break/reset to client 152 0.00 0.00
buffer busy waits 14 0.00 0.00
enqueue 1 0.61 0.61
</pre>
GaoYuanHi,
I've reformatted your output for better understanding (with {noformat}...{noformat}):
B_TIME E_TIME EXECUTIONS_DIFF EXEC_TIME CPU_TIME BUFFER_GETS EXEC_PER_DAY
2009-11-25-14:04 2009-11-25-14:23 8513 .0069 .0068 315.56 646329
2009-11-25-14:23 2009-11-25-14:43 10170 .007 .0068 312.28 726188
2009-11-25-14:43 2009-11-25-15:05 11873 .0072 .0069 320.17 787885
2009-11-25-15:05 2009-11-25-15:23 8633 .011 .0101 844.83 675014
2009-11-25-15:23 2009-11-25-15:44 9668 .0144 .0137 1448.51 680778
2009-11-25-15:44 2009-11-25-16:04 9671 .0163 .0156 1809.04 702163
2009-11-25-16:04 2009-11-25-16:25 10260 .0188 .0177 2107.67 711447
2009-11-25-16:25 2009-11-25-16:44 9827 .0157 .0151 1834.3 739593
2009-11-25-16:44 2009-11-25-17:05 10586 .0171 .0164 2008.25 714555
2009-11-26-08:04 2009-11-26-08:24 11028 .0182 .0172 1979.61 800688
2009-11-26-08:24 2009-11-26-08:44 10533 .0154 .0149 1734.62 750248
2009-11-26-08:44 2009-11-26-09:04 9367 .018 .0168 2043.95 685274
2009-11-26-09:04 2009-11-26-09:24 10307 .0214 .0201 2552.43 729938
2009-11-26-09:24 2009-11-26-09:45 10932 .0251 .0234 3111.48 762328
2009-11-26-09:45 2009-11-26-10:05 10992 .0278 .0254 3386.41 797404
2009-11-26-15:03 2009-11-26-15:16 7183 .0425 .0348 4615.42 746824
2009-11-26-15:16 2009-11-26-15:23 2921 .0417 .0373 4887.75 682092
2009-11-26-15:23 2009-11-26-15:43 9597 .0393 .0352 4603.62 679656
2009-11-26-15:43 2009-11-26-16:03 8797 .0411 .0362 4783.66 630755
2009-11-26-16:03 2009-11-26-16:23 9957 .0453 .0391 5168.28 718100
2009-11-26-16:23 2009-11-26-16:43 11209 .0436 .0369 4870.77 808395
2009-11-26-16:43 2009-11-26-17:03 10729 .0428 .0375 5119.56 766103
2009-11-26-17:03 2009-11-26-17:23 9116 .0409 .0363 4912.58 659098
call count cpu elapsed disk query current rows
Parse 76 0.03 0.00 0 0 0 0
Execute 76 4.58 5.14 0 567843 19034 76
Fetch 0 0.00 0.00 0 0 0 0
total 152 4.61 5.14 0 567843 19034 76
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 88
Rows Row Source Operation
1 UPDATE (cr=30 r=0 w=0 time=6232 us)
1 INDEX UNIQUE SCAN <PK Index Name(cr=3 r=0 w=0 time=58 us)(object id 81122)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
SQL*Net message to client 152 0.00 0.00
SQL*Net message from client 152 0.00 0.22
SQL*Net more data from client 1894 0.00 0.03
SQL*Net break/reset to client 152 0.00 0.00
buffer busy waits 14 0.00 0.00
enqueue 1 0.61 0.61
********************************************************************************Can you please provide a DDL for the table, indexes, type of the tablespace(s) they reside in (ASSM/MSSM, extents sizes), the UPDATE statement, how many sessions on average/peaks are doing the same thing concurrently, how many sessions are working this table concurrently and how do they use it?
Maybe you are looking for
-
How to send email in labview in intranet network
hii all... i am quite new to networking concept in labview... i want to develop a ayatem where on completion of particularevent an email will be sent to concerned person regarding the completion of task...ans the email should be autogenerated....mean
-
How do I drop the last 3 characters in a string?
Hello. I'm trying to find a way to drop the last 3 characters in a string. The length varies because it is a last name field. The problem is that when a customer has a suffix on their name, III for example, it is appended to the last name all in t
-
OBIEE 11g Initialization Block problem with WLS User
Hello, a brief description of my environment: - I have one machine with all OBIEE 11.1.1.6.2 components (build 120604.0813 BP1 64bit) and Oracle Database 11gR2; - In a separate machine I have the OID - Oracle Internet Directory where I have all busin
-
Do I need to pay anything to Adobe if I inject java script using some open source library?
Hello, I want to restrict PDF reader to achieve Digital Rights Management (DRM). Do I need to pay anything to Adobe if I inject java script to achieve so using some open source library? Basically I want my PDF documents to be restricted such that I c
-
CPU load growing slowly at exact pace
Hi all, I'm experiencing a weird thing since migrating from 10.5 server to 10.6 server: The CPU load grows slowly but steadily after each restart. After two days the server gives bad response, resulting in beachballs coming and going on both the serv