How to purge PERFSTAT.STATS$SQLTEXT table, after deleting snapshots

I had an alarm on the free space of the PERFSTAT tablespace. In order to free up some space I tried to delete some old StatsPack snapshots, with the following query:
DELETE from perfstat.stats$snapshot where snap_time < sysdate - 10 ;
COMMIT;
After running it the space usage on the tablespace was not significantly reduced. I checked again and I saw that the table PERFSTAT.STATS$SQLTEXT was very big, almost 8 Gb, but all the other tables were a lot smaller. I read somewhere that the sppurge.sql procedure, that comes with Oracle, could be used to purge the statspack data, but that it comes with the lines related to PERFSTAT.STATS$SQLTEXT commented, because it is a big query and it can take a lot of undo space. I tried to run the followiung query, which I found in the forum, by Don Burleson, but it failed, because of running out of undo:
DELETE /*+ index_ffs(st)*/
FROM perfstat.stats$sqltext st
WHERE (hash_value, text_subset) NOT IN (
SELECT /*+ hash_aj full(ss) no_expand*/ hash_value, text_subset
FROM perfstat.stats$sql_summary ss
WHERE snap_id NOT IN (SELECT DISTINCT snap_id FROM perfstat.stats$snapshot)
COMMIT;
Is there any way to know if the PERFSTAT.STATS$SQLTEXT table has records that could be purged, and an easier way, that don't use as much undo, to purge it?
My oracle version is:
Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
PL/SQL Release 9.2.0.7.0 - Production
CORE 9.2.0.7.0 Production
TNS for Solaris: Version 9.2.0.7.0 - Production
NLSRTL Version 9.2.0.7.0 - Production
I. Neva
Oracle DBA

Is there any way to know if the PERFSTAT.STATS$SQLTEXT table has records that could be purged, yes, just transform Delete to Select
SELECT /*+ index_ffs(st)*/ count(*)
FROM perfstat.stats$sqltext st
WHERE (hash_value, text_subset) NOT IN (
SELECT /*+ hash_aj full(ss) no_expand*/ hash_value, text_subset
FROM perfstat.stats$sql_summary ss
WHERE snap_id NOT IN (SELECT DISTINCT snap_id FROM perfstat.stats$snapshot)
and an easier way, that don't use as much undo, to purge it?yes. do it smaller chunks
BEGIN
LOOP
DELETE /*+ index_ffs(st)*/
FROM perfstat.stats$sqltext st
WHERE (hash_value, text_subset) NOT IN (
SELECT /*+ hash_aj full(ss) no_expand*/ hash_value, text_subset
FROM perfstat.stats$sql_summary ss
WHERE snap_id NOT IN (SELECT DISTINCT snap_id FROM perfstat.stats$snapshot)
) AND ROWNUM<=10000;
EXIT WHEN SQL%ROWCOUNT = 0;
COMMIT;
END LOOP;
COMMIT;
END;
/

Similar Messages

  • How to Remove Sort State in Table after display it in Table

    Hi
    I use the method below to sort the columns before displaying to the user and it works okay
    FieldKey testKey = new FieldKey("testField");           
                FieldKeySortCriteria testCriteria = new FieldKeySortCriteria(portCodeKey, true);
                this.getRowRecord1().addSort(testCriteria);the problem is in every rows i have edit button where user can edit and update particular row.
    the problem occurs whenever user change the value for particular field that is being sorted the row will jump randomly according to the sort rules.
    My Question is , how can we remove or disabled sorting as soon user see the result so it wont be jumping around if user changed the value of particular field that is being sorted.
    i dont find any removeSort() function in Rowgroup
    is there another way??
    Thanks

    i tried to put
    rowGroup.clearSort() in my Destroy() Method but is not disabling the current state of my rowgroup
    what it does is the moment i click edit button for particular row
    that row will jump to some other page ( because i did pagination on my table ) because the sort has been cleared .
    How do i clear and use the current state of my rowgroup after it has been displayed.

  • How to create outline from perfstat.stats$SQL_PLAN table

    How do I create outline (Plan stability in 10gR2database) from perfstat.stats$SQL_PLAN table?
    Current V$SQL_PLAN does not contain good but but week older snapshots have good plan.
    I can't modify query, it's vendor query so I need to create outline/plan stability.
    Thanks for help.

    user7478143 wrote:
    Thanks for reply.
    I'm not saying I find it out doc but here is situation.
    I have query which change execution plan week ago.
    I have perfstat enable and I found out good execution plan from perfstat.stat$SQL_PLAN view.
    If it's our query I can modify query and able to get good execution plan but it's vendor supplied query (which is Oracle - it used to be Portal now Oracle acquired it) so I can't modified it.
    All I'm trying to do is how do I generate good plan and assigned to vendor query's hash_value/sql_id.If DBMS_ADVANCED_REWRITE is not an option for you and you want to use an outline, there is one significant problem. The Statspack captured data does not include quite enough information, in particular the OTHER_XML column, and the access predicates. So, what can you do? Note that this script is from page 214 of the book that I co-authored. Let's say you execute this SQL statement:
    SQL> SELECT
      2    SQL_ID,
      3    COUNT(DISTINCT PLAN_HASH_VALUE) C
      4  FROM
      5    PERFSTAT.STATS$SQL_PLAN_USAGE
      6  GROUP BY
      7    SQL_ID
      8  HAVING
      9    COUNT(DISTINCT PLAN_HASH_VALUE)>1;
    SQL_ID         C
    0fr8zhn4ymu3v  2
    0h6b2sajwb74n  2
    1gu8t96d0bdmu  2
    39m4sx9k63ba2  2
    4b57myt9mpz37  3
    52tr7ay85qwn0  5
    …Interesting, SQL_ID has 2 different execution plans, let's take a look at the execution plans:
    SQL> SET LINESIZE 150
    SQL> SET PAGESIZE 10000
    SQL> SPOOL StatspackPlan.txt
    SQL> SELECT /*+ ORDERED */
      2    T.*
      3  FROM
      4    (SELECT DISTINCT
      5       PLAN_HASH_VALUE
      6     FROM
      7       PERFSTAT.STATS$SQL_PLAN_USAGE
      8     WHERE
      9       SQL_ID='0fr8zhn4ymu3v'
    10     ORDER BY
    11       PLAN_HASH_VALUE) SPU,
    12    TABLE(DBMS_XPLAN.DISPLAY(
    13      'PERFSTAT.STATS$SQL_PLAN',
    14      NULL,
    15      'TYPICAL -PREDICATE -NOTE',
    16      'PLAN_HASH_VALUE='||SPU.PLAN_HASH_VALUE)) T;
    | Id  | Operation                   | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |*  0 | SELECT STATEMENT            |            |       |       |     2 (100)|          |
    |*  1 |  TABLE ACCESS BY INDEX ROWID| OPQTYPE$   |     1 |    27 |     2   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | I_OPQTYPE1 |     1 |       |     1   (0)| 00:00:01 |
    | Id  | Operation             | Name     | Cost  |
    |*  0 | SELECT STATEMENT      |          |       |
    |*  1 |  SORT ORDER BY        |          |     0 |
    |*  2 |   TABLE ACCESS CLUSTER| OPQTYPE$ |       |
    |*  3 |    INDEX UNIQUE SCAN  | I_OBJ#   |       |
    --------------------------------------------------As can be seen by the above, in one case the I_OBJ# index was used, and in another case the I_OPQTYPE1 index was used. Let's assume that I_OPQTYPE1 is the most efficient access path, so a hint like this needs to be inserted (assuming that the table does not have an alias in the SQL statement:
    /*+ INDEX(OPQTYPE$ I_OPQTYPE1) */Now what (obviously, we would not want to actually fix the above plan for an internal SQL statement)? Take a look at the following, which shows how to build a private outline for the unhinted version of the SQL statement, an outline for a hinted version, and then swap the resulting outlines, followed by building a public outline from the hacked outline:
    http://hoopercharles.wordpress.com/2009/12/18/tracking-performance-problems-inserting-a-hint-into-sql-in-a-compiled-program/
    Charles Hooper
    Co-author of "Expert Oracle Practices: Oracle Database Administration from the Oak Table"
    http://hoopercharles.wordpress.com/
    IT Manager/Oracle DBA
    K&M Machine-Fabricating, Inc.

  • How to write SELECT statement using tables ekko,ekpo and eket?

    Hi,
    I got a problem in  performance tuning using below tables?
    how to write SELECT statement using tables EKKO,EKPO and EKET and in conditon ( WHERE clause)  use only fields 
                        ekko~ebeln       IN ebeln
                       ekko~loekz       EQ ' '
                       ekko~lifnr       IN lifnr
                       ekko~ekorg       IN ekorg
                      ekko~ekgrp       IN ekgrp          
                       ekpo~werks       IN werks
                       ekpo~pstyp       EQ  '3'
                       ekpo~loekz       EQ  space
                       ekpo~elikz       EQ  space
                       ekpo~menge       NE  0
                     eket~rsnum       NE space.
    Thanks in Advance.
    bye.

    Hi,
    ekko~ebeln IN ebeln
    ekko~loekz EQ ' '
    ekko~lifnr IN lifnr
    ekko~ekorg IN ekorg
    ekko~ekgrp IN ekgrp
    ekpo~werks IN werks
    ekpo~pstyp EQ '3'
    ekpo~loekz EQ space
    ekpo~elikz EQ space
    ekpo~menge NE 0          " Remove this from where clause
    eket~rsnum NE space.    " Remove this from where clause
    ' instead delete the entries after fetching into the table
    DELETE it_itab WHERE menge EQ '0' AND rsnum EQ ' '.
    Regards
    Bala Krishna

  • How can you get a calendar back after deleting it

    How can you get a calendar back after deleting it

    You will have to restore the device from a backup on icloud.  (this assumes you have backups turned on in settings>icloud)
    http://support.apple.com/kb/HT1766?viewlocale=en_US&locale=en_US
    Go to Settings>General>Reset and tap Erase All Content and Settings.  This will erase your device.  Then you will go through the setup screens again as you did when your device was new, and when given the option, select Restore from iCloud Backup.

  • Shrink Oracle Table after Deletion

    A few database tables are very big. An Oracle table still holds the disk space occupied by deleted records according to http://stackoverflow.com/questions/6540546/oracle-10g-table-size-after-deletion-of-multiple-rows. Re: shrink table after delete teaches the following commands to release the idle space from the table.
    ALTER TABLE TABLE1 DEALLOCATE UNUSED;
    ALTER TABLE TABLE1 ENABLE ROW MOVEMENT;
    ALTER TABLE TABLE1 SHRINK SPACE;
    ALTER TABLE TABLE1 MOVE;
    1. Are the commands feasible?
    2. Are they safe?
    3. What will be the impacts of running the commands?
    4. Is there any other workable safe approach shrinking a table?

    Hi,
    I advise using shrink table operation.
    The tablespace which belong to your table must be in ASSM (Automatic segment space management) to use shrink.
    Shrink is safe but you need to run two commands :
    1)ALTER TABLE TABLE1 SHRINK SPACE COMPACT; (This is long operation which moves data, but can be done online)
    2)ALTER TABLE TABLE1 SHRINK SPACE; (this is quick if you run SHRINK SPACE COMPACT before, it only shift the High Water Mark. Be carreful if you don't run SHRINK SPACE COMPACT before your table will be locked for a long time)
    Another point, is that execution plans are calculed using the HWM so SHRINK the table (The 2nd command) will invalidate all the cursors in shared pool where the table is in. So execution plan need to be recalculated (often not a problem).
    Regards,

  • How to reduce the size of file after delete some datas?

    The size of the database file isn't smaller than ago after delete some data from database.
    How to reduce the size of file after delete some datas?

    Hi,
    What BDB release are you using? If it's one of the latest releases, then what you are looking for is the DB->compact() method:
    http://download.oracle.com/docs/cd/E17076_01/html/api_reference/C/dbcompact.html
    The DB->compact() method compacts Btree, Hash, and Recno access method databases, and optionally returns unused Btree, Hash or Recno database pages to the underlying filesystem. Please let me know if it helps.
    Bogdan Coman

  • How to set current row in table after use tab key on inputText

    Hello all,
    My first post .., I'm newbie in ADF and I will try to explain my problem.
    For the moment we use ADF 11g (11.1.1.4), in a jsff page I have a table with an inputText column.
    On the valueChangeListener of the inputText, I invoke a method in a viewScope bean which call an EJB method, make some services in the EJB on the line modified. After that I refresh the VO and the table (because others values on the line have been modified) and reset the focus on the same inputText modified by the user with javaScript because focus was lost after refresh.
    So far, everything works fine.
    When I use the arrow keys to change the selected row in the table, it's work fine (focus is still in the next or previous inputText), but if user try to use tab key to change the current line, the inputText on the next line have the focus but the current row of the table is not changed (I think it's normal).
    My question : how can I change the current row after tab key pressed in this case ?
    I don't know if it's really clear, not easy to explain, don't hesitate to ask more details.
    Thanks in advance.

    Frank Nimphius wrote:
    Hi,
    My question : how can I change the current row after tab key pressed in this case ?
    Use a client event to listen for the keyboard entry and intercept the tab. The use af:serverListener to call the server to set the rowKey on the table and issue a PPR for the table to re-paint
    See sample 11 on http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html#CodeCornerSamples
    to learn about how to use the client listener and server listener
    FrankHi,
    Thanks a lot for your advices, I used the client and server listener
    I used this code on the method call in order to change the selection after key tab pressed, I don't know if it can be easier, but it works.
              if (LOGGER.isDebugEnabled()) {
              LOGGER.debug("START changeSelectedRow");
              RowKeySet oldRowKeySet = myTable.getSelectedRowKeys(); // get oldRowKeySet
              if (oldRowKeySet == null) {
                   if (LOGGER.isDebugEnabled()) {
                        LOGGER.debug("oldRowKeySet is null");
                   return;
              RowKeySetImpl newRowKeySet = new RowKeySetImpl(); // The new RowKeySet use to change the selectedRow
              DCIteratorBinding bindingIterator = ADFUtils.findIterator(MY_ITERATOR);
              bindingIterator.setRangeSize(-1);
              // set the new index of the current row.
              int index = bindingIterator.getCurrentRowIndexInRange();
              if (index < bindingIterator.getAllRowsInRange().length - 1) {
                   index++;
              bindingIterator.setCurrentRowIndexInRange(index);
              // get the current row after changed the index
              Row currentRow = bindingIterator.getCurrentRow();
              if (currentRow != null) {
                   ArrayList nextLst = new ArrayList(1);
                   nextLst.add(currentRow.getKey());
                   newRowKeySet.add(nextLst);
                   // set the new selectedRow
                   myTable.setSelectedRowKeys(newRowKeySet);
                   SelectionEvent selectionEvent = new SelectionEvent(oldRowKeySet, newRowKeySet, myTable);
                   selectionEvent.queue();
                   AdfFacesContext.getCurrentInstance().addPartialTarget(myTable);
              if (LOGGER.isDebugEnabled()) {
                   LOGGER.debug("END changeSelectedRow");
    Best Regards
    Benjamin

  • How to not getting record in table after refreshing my page?

    Hi,
    I am using jdev 11.1.1.2.3
    My problem is,.. i am performing deleting operation my table for deleting record in that time it is deleted,
    But in my problem is after refreshing the page record is coming back.
    I am performing delete operation using bindings
    can any one help me..
    Thank You..

    Hi,
    Actually i create global components insert delete,commit,first,next these all are icons in my template page
    when i am using any master table click on those icons i perform operations
    for bindings
    insert:#{backingBeanScope.AdminCountryBean.addNewCountry}
    savecall:#{AdminMainActionBean.pofAdminAction}
    cancelcall:#{bindings.Delete.execute}
    For inserting and saving i write bean class deleting i am not following any programmatic approach....

  • HT1766 How can i restore all my data after deleting the apps? can i syncing back from the macbook?

    How can i restore back all my data after deleting the apps and re-install back.
    After reinstall back stll retrieve all my data.
    Can i syncing back the original frm my macbook since last update is Mar

    Favor the route via iTunes and local storage on the computer. MUCH faster than any cloudy backup, no matter the speed of your Internet connection. No network beats the speed of a hard drive. Just make sure there's enough room on the computer before you start, must contain all that's on the iGadget.

  • How to get the final internal table after the ALV is modified?

    Dear experts,
    My WebDynpro application allows users to delete row, sort the column. After all this modification, I need to get the final internal table of ALV to generate a csv.file. Are there any methods to get the final interal table content of ALV?
    Many thanks!
    meer

    Hi Friend  ,
    Please see this  link for wiki of  WDA Alv Hierarchy : [http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/c060fcb4-2c62-2b10-d2b2-f32407a5cc6f&overridelayout=true]
    Regards,

  • How to maintain data of a table after I created the structure of it?

    If I does not create a maintain view in SM30, can I also be able to input data without writing a programme.
    Best regards,

    Check the check box of                            
    Table Maintainence allowed in Attributes tab of table
    and then go to
    utilities->table contents->create Entries.
    Reward if useful.
    Devi

  • Restoring the data from table after deletion

    Hi,
    If  I delete the data from the database (using delete command) , is there anyway to restore that data. I know it looks bit weird but I'm checking whether there is any technique in abap by which we can restore the data.
    Your help would be appreciated.
    Thanks,
    Kranthi.

    Hi Kranthi,
               When you delete lines of a database table using the DELETE command, the process is only complete after a database commit. Before the commit, any database change can be reset using a database rollback.To be able to perform a database rollback, a database system must generate a copy of each database object before making a change. These copies are kept in a rollback log until the end of an LUW. An overflow of the rollback log always results in the termination of the transaction which caused it. For example, attempting to remind a large number of defaulting customers in the same transaction could trigger such an error. You can only solve this problem by dividing the set of database updates into several smaller units ( LUWs) for the database system. You use this statement if you cannot be certain that all the database changes have been executed correctly.
    For your information :
    An LUW begins each time you start a transaction,when the database changes of the previous LUW have been confirmed (database commit) or when the database changes of the previous LUW have been cancelled (database rollback)
    An LUW ends when the database changes have been confirmed (database commit) or when the database changes have been canceled (database rollback). Within an LUW, database changes are not made until after a database commit. Prior to this, any database change can be canceled by a database rollback.
    Cheers
    Nishanth

  • Shrink table after delete

    Hi,
    I want to remove some data from a Oracle table, too free up some space on hard drive.
    I use delete clause with where condition to delete data, but then after i would need some shrink clause to shrink up the table as i understand.
    I cant use truncate because it doesn't allow to use where clause. I need something like:
    delete from table 1 where condition1;
    shrink table1; --rfree up space                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Simply deleting rows doesn't make blocks eligible for deallocation. Try this:
    truncate table mette reuse storage;
    CALL DBMS_STATS.GATHER_TABLE_STATS(USER,'mette');
    SELECT t.blocks used, s.blocks allocated
    FROM   user_tables t JOIN user_segments s ON s.segment_name = t.table_name
    WHERE  t.table_name = 'METTE';
       USED ALLOCATED
          0     20480
    alter table mette deallocate unused;
    CALL DBMS_STATS.GATHER_TABLE_STATS(USER,'mette');
    SELECT t.blocks used, s.blocks allocated
    FROM   user_tables t JOIN user_segments s ON s.segment_name = t.table_name
    WHERE  t.table_name = 'METTE';
       USED ALLOCATED
          0         8
    alter table mette allocate extent;
    -- ...same query...
       USED ALLOCATED
          0        16
    alter table mette deallocate unused;
    -- ...same query...
       USED ALLOCATED
          0         8

  • How to compress (or cleanup) Sqlite database after delete?

    Is there a way to compress (or cleanup) a Sqlite database after a large number of rows have been deleted?
    For example, if I have a database file around 1Mb and delete all the rows the database file remains at 1Mb (despite being empty). If I then open this file in Sqlite Administrator and click on "CleanUp" the size goes down to 4kb.
    Is this functionality available from inside my app?
    Thanks

    I'm finally getting some time to look at this but not doing too well.
    Running the following code gives the below error message:
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *path = [documentsDirectory stringByAppendingPathComponent:@"myDB.sql"];
    int success;
    if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
    // My first delete statement
    // My second delete statement
    // My third delete statement
    // VACUUM STATEMENT
    const char *sql4 = "VACUUM";
    sqlite3_stmt *statement4;
    if (sqlite3preparev2(database, sql4, -1, &statement4, NULL) != SQLITE_OK) {
    NSAssert1(0, @"Error: failed to prepare vacuum with message '%s'.", sqlite3_errmsg(database));
    success = sqlite3_step(statement4);
    sqlite3_reset(statement4);
    if (success != SQLITE_DONE) {
    NSAssert1(0, @"Error: failed to execute vacuum with message '%s'.", sqlite3_errmsg(database));
    sqlite3_finalize(statement4);
    sqlite3_close(database);
    error:
    Error: failed to execute vacuum with message 'unable to open database file'.
    I know the database file is open ok because the rows are being deleted fine. The problem is just cleaning up the database file with the VACUUM command.
    Has anyone successfully run this statement on the iPhone?

Maybe you are looking for

  • Problem creating a link to a network folder

    I am working with a SharePoint 2010 site. Due to not being able to utilize SharePoint Designer, I am limited to editing the site by first navigating to the SharePoint site and then selecting edit page from the site options menu. I have a table setup

  • WRP1 - different PO for same vendor/Purchase group/center

    Hi Guys, I am facing an issue in a client like these: We are running the WRP1 and it is creating multiple purchase orders for the same combination: vendor/Purchase grup/center. It should generate 1 PO per combination mentioned. I found the note 41870

  • JSPX page inside (i)frame is blank in IE

    I have a simple login.jspx that does not load correctly when it is placed in a frame or an iframe. Chrome and Firefox show no problems, but with Internet Explorer, the frame is blank. When loading the JSPX outside a frame, the application works as us

  • Should I add Yosemite on a slow 2009 Imac

    Hi Everyone, I am debating loading the new OS on my old little Imac. It is running slow and I just bought more Ram that should bump it up 8GB? If I have room it maybe 12GB. I get the spinning wheel and web pages take a long time to load along with ap

  • Help in controlling database online.

    Hi there, I'm very new to web application development, I'm in the process of testing dreamweaver cs3 and Developer toolbox, so far everything is very interesting, lots of good example everywhere but here is what I would like to accomplish and I don't