Quickest way to count table'srows

Hi,
Can someone tell me the quickest wayo the count the number of rows in a table. I have large tables (many many millions of rows) and would like to obtain the row count as quickly as possible as i will be monitoring the size via OCI;
Cheers,
Warren

Donald
Can you prove that SELECT COUNT('X') FROM ..
is faster than SELECT COUNT(*) FROM ...
The suggestion for keeping the table analyzed then select NUM_ROWS from all_tables is good, Except that for an OLTP application, this would not be very practical.
If possible what can be done is
Create Table MY_TAB_COUNTS (NUM_ROWS NUMBER);
Insert into MY_TAB_COUNTS (select count(*) from THE_TABLE);
COMMIT;
Create or Replace Trigger T_AID_COUNTS
AFTER insert or delete on THE_TABLE
FOR EACH ROW
declare
begin
  if INSERTING then
     update MY_TAB_COUNTS Set Num_Rows = (Num_Rows + 1);
  else
     update MY_TAB_COUNTS Set Num_Rows = (Num_Rows - 1);
  end if;
end;
/Then, when the row counts is needed:
Select Num_Rows from MY_TAB_COUNTS;

Similar Messages

  • Creation of staging table - quickest way.

    Hi,
    I need to create a staging table with roughly 370 fields. The sources' specs are not clear and some of the staging table's fields, too. So effectively, first of all I need to understand the staging fields and the source fields. The end user has been given some target date with some generic guess-work (not by me).
    I would like to know the best approach to complete the activity quicker - at least, document all the staging fields and source fields. What I have now is one Excel file with four columns - Staging Field, Source table and field, Staging Field Type and Staging Field Length. Out of the total 370 staging fields, I have just completed 50% and the target date is approaching faster - I have not touched developing Oracle package yet.
    This could be a generic question, but in order to meet deadline, could you please throw some light on the quickest way/tips to complete the mapping documentation (or creating the staging table)?
    Thanks in advance,
    Manoj.

    MDixit wrote:
    Hi,
    I need to create a staging table with roughly 370 fields. The sources' specs are not clear and some of the staging table's fields, too. So effectively, first of all I need to understand the staging fields and the source fields. The end user has been given some target date with some generic guess-work (not by me).
    I would like to know the best approach to complete the activity quicker - at least, document all the staging fields and source fields. What I have now is one Excel file with four columns - Staging Field, Source table and field, Staging Field Type and Staging Field Length. Out of the total 370 staging fields, I have just completed 50% and the target date is approaching faster - I have not touched developing Oracle package yet.
    This could be a generic question, but in order to meet deadline, could you please throw some light on the quickest way/tips to complete the mapping documentation (or creating the staging table)?
    Thanks in advance,
    Manoj.The first thing that comes to mind is the unclear specifications. (actually the first thing that came to my mind was that tables have columns not fields, but anyway......)
    you need to clarify what is coming from the source system before you will be able to intelligently map that to your target system. you may have to push back on your client and tell them that the deadline can't be met unless they provide more information about their source system.
    how have they chosen those 370 columns? how did they know these needed to be part of whatever process you are completing? if they know that these need to be moved to a target system then they should be able to tell you why.

  • Whats the quickest way to export packages,tables etc from one enviroment

    Hi
    whats the quickest way of more loads of packages, tables, indexes etc. from one enviroment to another?
    I did some things in apex.oracle.com workspace to test apex now I want to move it across to my xe installation.

    Hello,
    2 'fast' options really -
    1) Export of application + Export/DataPump of schema
    This works if you want a complete 'mirror' from one environment to another of the schema objects
    2) Supporting Objects
    Bundle all your requirements together with the application export.
    The Supporting Objects feature absolutely rocks and yet very very (very!) few people seem to use it.
    John.
    http://jes.blogs.shellprompt.net
    http://apex-evangelists.com

  • Looking for a better way to count responses to survey questions

    Hello all - I've created a survey for a site and now want to display the results for the site admins. I am simply trying to display the counts - the number of times a question has been answered a certain way. I realize that I may need to construct the survey itself differently and how it stores the data, but here's how it goes so far.
    There are 10 questions, each with 4 options in radio button groups. The database table has a column for each question and stores the value of the selected radio button. So that's pretty simple.
    Now on the results page this is the only way I can think of doing it, but there has to be a better way. For each response, I create a recordset filtered on the question and option value, then display the total record count. That works just fine, but to count each option, that means 40 recordsets on the page - al to merely determine "How many times was Question 1, Option A selected, and How many times was Question 1, Option B selected, and so on.
    The only other thing I can think of, there perhaps is a better way to count the occurrences of these values in the table either with PHP or in the SQL itself.  Or, perhaps if the values themselves are all numeric and follow some sort of pattern I can use a math solution.
    Any thoughts, solutions and ideas are welcome!  Thanks. 

    THANK YOU!!
    I used this format before actually for an exam in an online training program, and I don't know why I didn't make the connection.
    I also want to connect the responses to the participant, but I think that would even be secondary to the survey itself.
    So just to clarify, if you would, I would have a survey table l like I do now, with each survey generating an ID with each one and perhaps the user info or a column for User ID. Then, the questions table each with an ID to populate the questions, a options table, each with its own ID and linked to the questions that populate the options.
    Finally a responses table that records the Survey ID, Question ID and Option ID with each record.
    In the exam I did before, the questions and responses were in the same table, so I suppose I could make it work that way too. But, now I know why I didn't think of this - unlike the exam where each question was presented one at a time, the survey is on a single page and would require a multiple record insert - which I haven't done as much as single inserts, so it didn't pop into the head.
    L

  • What is the quickest way to incorporate a new template's styles into an existing template?

    Recently my company have developed a new template. I am creating a document using much content which already exists in an older template with different paragraph styles, table formats and page formats. What is the quickest way to incorporate the new styles so I don't have to individually update the table contents. The paragraph catelog and tables have different titles in the two documents.
    Thanks,
    Niall.

    Do you know where I can find a copy of Template Mapper? I went to http://ig5authoringtools.com/plugin-directory/single-sourcing/templatemapper/ and it is not there.
    Thanks in advance

  • Quickest way to see if a city (52000 records) is inside a string

    Hi,
    I am reading emails lines  in c# and interop.outlook, and I need to know if in that line there is a city. The table is around 52000 records! Sql Server 2012
    Thks in advance

    think table with 52000 cities  with field name as primary key
    seq ,  name
    1     Lisbon,
    2     London
    3      Paris
    4     Venice
    5     Istanbul
    6      Prague
    7      Florence,
    52000  Setubal
    Now I read one email line that says
    "I will be at Prague the 20 June. Get me at Airport"
    another line read
    "I will arrive at Lisbon the 25 June"
    I want the Quickest way to  get the city Prague after reading the first line and
    Lisbon after reading  the second.
    Thks
    N

  • HT1417 What's the quickest way to delete duplicates without going song by song?

    What is the quickest way to delete duplicates from i tunes library without going song by song?  I just transferred my music from my ipod classic to my computer and now I have a lot of duplicate music.  Most is from CD's I reburned or music I was able to get back on my new computer through I tunes.  It is from my personal i pod (one of 4).  I finally figured out how to get it off the ipod and back onto my newer computer. I made sure to go to advanced setting and check "keep i tunes folder organized" but it still saved all duplicates.

    Apple's official advice is here... HT2905 - How to find and remove duplicate items in your iTunes library. It is a manual process and the article fails to explain some of the potential pitfalls.
    Use Shift > View > Show Exact Duplicate Items to display duplicates as this is normally a more useful selection. You need to manually select all but one of each group to remove. Sorting the list by Date Added may make it easier to select the appropriate tracks, however this works best when performed immediately after the dupes have been created.  If you have multiple entries in iTunes connected to the same file on the hard drive then don't send to the recycle bin.
    Use my DeDuper script if you're not sure, don't want to do it by hand, or want to preserve ratings, play counts and playlist membership. See this thread for background and please take note of the warning to backup your library before deduping.
    (If you don't see the menu bar press ALT to show it temporarily or CTRL+B to keep it displayed)
    tt2

  • Fastest way to count the number of occurences of string in file

    I have an application that will process a number of records in a plain text file, and the processing takes a long time. Therefore, I'd like to first calculate the number of records in the file so that I can display a progress dialog to the user (e.g. " 1234 out of 5678 records processed"). The records are separated by the string "//" followed by a newline, so all I need to do to get the number of records is to count the number of times that '//' occurs in the file. What's the quickest way to do this? On a test file of ~1.5 Gb with ~500 000 records, grep manages under 5 seconds, whereas a naive Java approach:
    BufferedReader bout = new BufferedReader (new FileReader (sourcefile));
                   String ffline = null;
                   int lcnt = 0;
                   int searchCount = 0;
                   while ((ffline = bout.readLine()) != null) {
                        lcnt++;
                        for(int searchIndex=0;searchIndex<ffline.length();) {
                             int index=ffline.indexOf(searchFor,searchIndex);
                             if(index!=-1) {
                                  //System.out.println("Line number " + lcnt);
                                  searchCount++;
                                  searchIndex+=index+searchLength;
                             } else {
                                  break;
                   }takes about 10 times as long:
    martin@martin-laptop:~$ time grep -c '//' Desktop/moresequences.gb
    544064
    real     0m4.449s
    user     0m3.880s
    sys     0m0.544s
    martin@martin-laptop:~$ time java WordCounter Desktop/moresequences.gb
    SearchCount = 544064
    real     0m42.719s
    user     0m40.843s
    sys     0m1.232sI suspect that dealing with the file as a whole, rather than line-by-line, might be quicker, based on previous experience with Perl.

    Reading lines is very slow. If your file has single byte character encoding then use something like the KMP algorithm on an BufferedInputStream to find the byte sequence of "//\n".getBytes(). If the file has a multi-byte encoding then use the KMP algorithm on a BufferedReader to find the chars "//\n".getCharacters() .
    The basis for this can be found in reply #12 of http://forum.java.sun.com/thread.jspa?threadID=769325&messageID=4386201 .
    Edited by: sabre150 on May 2, 2008 2:10 PM

  • Quickest way to resizing 30 documents

    I have 30 documents (all in all 400 odd pages) that all need completely re artworking to a smaller size - but not one that is the same proportions height and width. As a starting point I want to resize all documents to 50% - is there an apple script or similar software that will make this task simple.
    Any help would be welcome.
    Thanks

    I would hesitate to let any script run rampage on this.
    By far the easiest way is one of printing the document to PDF and placing that, or directly placing the original ID document as image, into a new document of the correct size. But that restraints you to proportional sizing only -- your 50% should work fine, but if you enter a different scale for horizontal and vertical, you will see text and images distort. And (since you might ask), no, a script would not help here.
    There are a couple of scripts that place entire PDFs automatically (search in the script repository).
    There is no easy way to reformat a document. The only help you can get is by enabling Layout Adjustment, and its use is very limited. It does its work flawless when done with plain text only (say, a novel), but as soon as you have images and/or tables in floating boxes, it does resize them (in a haphazard way -- tables are not re-fitted) but no way it can keep them "on the same page as the reference", or something like that.
    If you are looking for the quickest way, and don't care about quality, go for proportionally resized PDFs (using a script). If you do care for some quality, do not resize them out of proportion -- and you can still use a script. But if you want to do any editing at all -- no matter how tiny -- you will have to resize and reformat the document manually, no way around it.

  • Is there an easy way to count the number of albums I have in my library?

    Hi, there is probably a very easy way to find out how many albums I have in my iTunes library - but I haven't discovered it yet! (looking for something a bit like word count in MS Word document?)
    Powerbook G4 15 1.67   Mac OS X (10.4.3)   my first Mac - where have I been!?!

    Click on the Library icon in the source list Go Edit->Show Browser.
    This will split the library window into subwindows listing each genre, artist and album, at the top of these windows it will show the total for each of these categories.
    Apart from being the easiest way to count your albums, it's also a really useful way to view the library or any playlist. You can turn off the genre subwindow through the general preferences.
    Hope that helps!
    Sara.

  • Is there any way  to create table  of more than 30 char length name

    hi all,
    Please tell me is there any way to create table of more than 30 char length name in oracle 10g
    Regards

    Hi,
    If you want table name to be more than 30 Char.
    I am sure,your naming convention is not upto the mark.
    Its not possible in 10g as well as in 11g.
    Thanks
    Yogesh Nagle
    India

  • What is the quickest way to access the Settings on an iPad?

    What is the quickest way to access the Settings on an iPad? (I mean, the usual cogwheel "app" called Settings)
    In particular, I'm looking for a quicker way (or a more convenient one) to access it from an open application, than hitting the "home" button, possibly swiping the home pages, and tapping on it.
    (I know, I know, I already placed it in the bottom bar, so I have it available from all pages...)
    It would be great if I could cut another step or two. I mean, there are situations where I need to use the Settings app repeatedly. I wonder why it was not included in the iOS 7 swipe-from-bottom menu, while the "Camera" or "Countdown Timer / Clock" made the cut.
    I know everybody will have a different opinion on what should be included in that menu, and choices have to be made, but still...
    for example, on my Android smartphone the newer OS updates placed a shortcut to the settings app in the upper-right corner of the swipe-down menu, which is like the most prominent place you could place it in.
    Anyway, do you know of one or more alternative ways to access the Settings app?
    (Oh, and yeah, it just occurred to me that I can four-finger swipe it, if I have accessed it recently, but again if I access another app or two in between it will become at least as cumbersome as going through the home page).

    Anyway, do you know of one or more alternative ways to access the Settings app?
    Short answer, no. If you have a suggestion for future iOS functionality, use the feedback functionality found elsewhere on this site.
    Barry

  • HT1349 what is the quickest way to move all my iTunes music, video, etc. to a new computer? any help would be appreciated.  thanks.  p.s. i purchased a belkin transfer cable - will that work?

    hi - i'm a newbie - what is the quickest way to move all my iTunes music, video, etc. to a new computer? any help would be appreciated.  thanks.
    p.s. i purchased a belkin transfer cable - will that work?  i have an iPod Touch.

    You copy it from one computer to the other.
    Type "move itunes library" into the google search bar.
    You have posted in the iphone forum.

  • Different Ways To Gather Table Statistics

    Can anyone tell me the difference(s), if any, between these two ways to refresh table stats:
    1. Execute this procedure which includes everything owned by the specified user
    EXEC DBMS_STATS.gather_schema_stats (ownname => 'USERNAME', degree => dbms_stats.auto_degree);
    2. Execute this statement for each table owned by the specifed user
    analyze table USERNAME.TABLENAME compute statistics;
    Generally speaking, is one way better than the other? Do they act differently and how?

    In Oracle's automatic stats collection, not all object are included in stats collection.
    Only those tables, which has stale stats are taken for stats collection. I don't remember on top of my head, but its either 10% or 20% i.e. the tables where more than 10% (or 20%) data has changed are maked as stale. And only those stale objects will be considered for stats collection.
    Do you really think, each and every object/table has to be analyzed every day? How long does it take when you gather stats for all objects?

  • What is the quickest way of moving a itunes music library from a windows 7 machine to an apple Macbook pro?

    What is the quickest way of moving an itunes music library from a windows 7 machine to an apple Macbook pro?

    If you wany Everything from your PC itunes on your MBP... Then... See Here...
    Move iTunes Library from PC to MAC
    http://www.macworld.com/article/146958/2010/03/move_itunes_windows_mac.html

Maybe you are looking for

  • Flexunit on a headless mac server

    Has anyone successfully ran flexUnit on a headless mac? im running ant builds via Jenkins, it will build a flex app no problem, however when I try to build the sample flexunit CI app I get the followin error [flexunit] LSOpenURLsWithRole() failed wit

  • Can I import a tablespace into Oracle 10g Express Edition

    I am very new to Oracle 10g Express Edition. We have a server running Oracle Enterprise Edition and we have been creating a transportable tablespace to be imported into a few servers. This works fine for us. I would like to find out if I can import t

  • Error when trying to purchase Flash Pro

    I am trying to buy a subscription to flash pro but keep on getting this error; I cant call the number because I am outside the US

  • Resizing of tablespace size in db2

    My database is DB2 with ECC6.0.we have 35 table spaces among all 13 almost 98.8%used. how can we resize the table spaces using or database level.

  • Installtion error

    Hi, I am trying to install NW 7.3 standard system mode.  In the process i faced one problem C:\Users\ADMINI~1\AppData\Local\Temp\2\sapinst_exe.684.1322216717\SAPCAR.exe -x -v -i -f "G:\NetWeaver 7.3 Extract\NW 7.3 Kernel, Inst.Master, Upgr.Master WIN