Simple Order of Magnitude counts.. do they exist ?

I don't normally deal with SQL, so apologies if what I am asking is dumb / obvious.
I have a table [orders] with approx 300,000,000 rows. It is quite wide (approx 500b on avg).
there is a unique index [idx_a] on [order_id , order_dt, store_chain, store_id]
there is another index [idx_b] on [order_dt, ...several other columns...]
At a high level I want to do something like:
SELECT TO_CHAR(order_dt, 'YYYY'), COUNT(*)
FROM orders
GROUP BY order_dt
But I am not really interested in the exact count, I am more interested in an order of magnitude summary. The system is online and live and continually accepting orders from the various outlets (approx 20 per minute). I have tried running the above query, in a test environment but it does not complete inside of 15 minutes.
Is there a smarter way to do this ?

Howler_Fish wrote:
At a high level I want to do something like:
SELECT TO_CHAR(order_dt, 'YYYY'), COUNT(*)
FROM orders
GROUP BY order_dt
But I am not really interested in the exact count, I am more interested in an order of magnitude summary. The system is online and live and continually accepting orders from the various outlets (approx 20 per minute). I have tried running the above query, in a test environment but it does not complete inside of 15 minutes.
Is there a smarter way to do this ?Apart from the other advices you've already got, you could try to use "sampling" if you're actually interesting in just a "rough" estimate:
SELECT TO_CHAR(order_dt, 'YYYY'), COUNT(*) * 10 as cnt
FROM orders sample (10)
GROUP BY order_dt;
This would "sample" only 10% of the rows using the "SAMPLE" clause, therefore you would have to multiply the count by the same factor to get results comparable to the "actual" query.
Please note that depending on how "skewed" the distribution of your data is across the table blocks if you use only a low sample size your results might be way off, so you might need to test with a different degree of sampling.
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/

Similar Messages

  • How can I get my log-scaled chart to zoom in closer than one order of magnitude?

    I have data that sometimes varies over many orders of magnitude, and sometimes varies narrowly. To handle the former gracefully, I chose to use a log scale on the chart for this data. However, when the differences are subtle, the chart does not close in any tighter than 1 order of magnitude.
    Is there a way to get the chart to come in closer automatically? I've definitely seen ticks for 3.5*10^N, not just 1*10^N - but now they don't appear, let alone using them as the boundaries of the graph.
    I'd rather not have to track the chart data in the program and use property nodes to change the scale programmatically myself!
    Solved!
    Go to Solution.

    altenbach wrote:
    Here is the property description. (If loose fit is off, the scale goes from the data minimum to the data maximum.)
    I've seen this, but was not getting a clear picture, how the graph looks with 'Loose Fit' True and how it looks when this property is False...!!
    I'm too lazy, so was asking you to make one...!!
    Anyways... I made it myself.
    I am not allergic to Kudos, in fact I love Kudos.
     Make your LabVIEW experience more CONVENIENT.

  • How to check a list of users against AD if they exist

    Hi Scripting Guys,
    I have a powershell script that allows me to query a list of users against AD, and if they exist, it will write their details into a new file.
    I want to adapt this script so that it will still do the same, but if the user does NOT exist anymore, write a line such as "<User-ID> does not exist in AD".
    Here's the code I have so far:
    Import-Module ActiveDirectory
    $UserList = get-content C:\temp\checkAD\Accounts.txt
    Foreach ($Item in $UserList) {
    Get-aduser -filter {samAccountName -eq $Item} | Out-File C:\temp\checkAD\existingAccounts.txt -encoding default -append
    Does anybody know how to achieve that?
    Thanks and best regards,
    Cap'

    Function LDAP_query{
    param
    [Parameter( Mandatory=$true )][String[]]$cID
    # change the DCs to your domain information
    $root = [ADSI]"GC://dc=$($cID[0]),dc=company,dc=com"
    $searcher = new-object System.DirectoryServices.DirectorySearcher($root)
    $searcher.filter = "(sAMAccountName=$($cID[1]))"
    #running LDAP query
    $cAcc = $searcher.findall()
    if($cAcc.Count -ne 0){
    return ($cAcc[0].Properties["samaccountname"][0])
    else{
    Write-Host -BackgroundColor Black -ForegroundColor Red "Error with account:" -NoNewline
    Write-Host " $($cID[0])\$($cID[1])"
    return ""
    The function is waiting for a string array: [domain][user id]
    Return the string of the User ID if valid, return an empty string if not a valid ID

  • In pages, when a create a document, potions of it, say several pages will be clumped together and it effects me editing their order.  It is like they are forever joined- How do I edit my document and print just one page or move just one page?

    In pages, when a create a document, potions of it, say several pages will be clumped together and it effects me editing their order.  It is like they are forever joined- How do I edit my document and print just one page or move just one page?

    May you open your eyes before creating a new thread ?
    Your question was already asked and answered today.
    https://discussions.apple.com/thread/3177074?tstart=0
    Yvan KOENIG (VALLAURIS, France) jeudi 14 juillet 2011 14:40:40
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8
    Please :
    Search for questions similar to your own
    before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • How do I change the size of the tools and the text for the menus in Photoshop?  I need a magnifying glass in order to make out what they are.

    How do I change the size of the tools and the text for the menus in Photoshop?  I need a magnifying glass in order to make out what they are.

    Okay, I've figured it out, so I'm going to answer my own question in hopes that it may help anyone else that would like to actually be able to see what they're doing when using Photoshop CC 2014 on a high resolution screen.
    1.  Open Photoshop.
    2.  Select Preferences from the Edit Menu, then select General.
    3.  Change the HUD Color Picker to Hue Strip (Medium).
    4.  Select Interface from the Preferences menu on the left side of the dialog box.
    5.  Change the UI Font Size to Large in the Text area of the Preferences dialog box.
    6.  Select Experimental Features from the Preferences menu on the left side of the dialog box.
    7.  Select Scale UI 200% for high-density displays (Windows only).
    8.  Click on OK, then Exit/Quit Photoshop.
    9.  Open Photoshop and everything should be readable.

  • How can I get the songs in my iPod Nano to sort in numerical order?....they show up tht way on iTunes, but on the Nano, they're out of order.

    they show up that way on iTunes when connected to the Nano, (in numerical order) but on the Nano, they're out of order.  The shake to shuttle is off.

    I dragged and dropped it from my desktop to my Nano (through iTunes) and it all loaded in order...if I take it from iTunes, it syncs everything, not just one playlist....even though I choose only one playlist...
    ??? So you are manually managing your iPod's contents. i.e you drag and drop content onto your Nano from under the Devices section in the left hand pane of iTunes.
    What did you drag and drop?
    B-rock

  • I am looking for educational posters from Apple or for Garageband, if they exist. I'll be teaching a new class for middle school using Garageband next year. Thanks!

    I am looking for educational posters from Apple or for Garageband, if they exist. My school district will be teaching a new class for middle school using Garageband next year. I'd love to make the rooms look awesome! Can anyone hook me up? Thanks!

    lucky14life wrote:
    first i was wondering what everyone thinks about macbooks compared to let's say another pc like hp,dell,etc.... i have been told that i'd have to be dumb to get a machine with windows vista on it,so that is why i have turned my focus to a macbook because i have heard they are pretty good and worth it...
    I personally like my MacBook better than any other computer I have ever owned. I like being able to use windows when I need to but not being tied to it. My wife bought an HP with Vista and it doesn't seem to bad. Lots of updates at least one a week. Mostly graphic card drivers update.
    also is it true that if you upgrade let's say the memory,hard drive,etc it won't be covered in the warranty/apple care plan??
    Only two things you can upgrade on a MacBook is the Hard drive and Memory. It will not void the warranty. This is apples word on it. DIY Warranty Info
    I would just like to ask for people's opinions please on purchasing one of these i am currently a senior in college and will be using it next year for grad school,need to replace the one i currently have...
    Be sure you can live with the graphics. If you do a lot of graphics work you might want to consider the MacBook Pro. I use my MacBook for video editing using Final Cut Express HD and it works well. The MB is also not very good for gaming if you are into that. The integrated chip set doesn't work well with 3D games.
    also any other ideas on getting iwork or office, a hard plastic case or a skin,thanks alot for anyone's input it is greatly appreciated.... i am looking to get one once leopard comes out thanks!!
    Depending on your school may be a factor in what you choose. I use iWork and it is pretty good. You could also try NeoOffice or Open Office. They are good also. Office is supposed to be coming out with a new Mac version but not sure yet how it will work.
    Be sure to ask for the student discount when you purchase the computer and software. It adds up.

  • Sales order stock 110000193 000050 does not exist

    Hi Friends,
    I have a problam in Confirmation of Production order against sales order. Every time I confirm the production order system give an error message Sales order stock 110000193 000050 does not exist.
    where I check the material in mb52 transaction , the stock shows on that material.
    Please give solution .
    thanks in advance.
    Ajit Sharma

    Hi,
    It seems you have activated back flush some or all the components.
    In MTOscenario, system looks for sales order stock for all the components.
    Since sales order stock is not available with your system the message.
    Try with movement type 412E in MB1b to transfer components from U/R to sales order stock.system propmts you to give sales order number Pl. provide there & carry out transactuion.
    Then the system will pick up the stock & post.
    Regards,
    R.Brahmankar

  • I've had 2 Iphone 6plus stolen last 2 weeks. I am a reasonably careful 50 years old who's had a cell phone since they exist. Surely Apple can think of a way to make these stolen phones more difficult to re-use ?

    I've had 2 Iphone 6plus stolen last 2 weeks. I am a reasonably careful 50 years old who's had a cell phone since they exist. Surely Apple can think of a way to make these stolen phones more difficult to re-use ? No matter the precautions, a cell phone is easy to steal. But it seems even easier to re-use stolen cell phones. I had "find my phone", passwords, and another tracking device on my second stolen phone. Thieves just shut it off and wipe it. You would think with all the technology available, these phones could be rendered completely useless if stolen. Unless of course this "second hand market" is considered valuable.

    Your best bet is to as soon as you realize your device has been stolen is to go to iCloud.com on your computer and put the device in Lost Mode. This gives you the opportunity to not only add a Lock to the screen, but also to send a message to the lowlife who stole you phone, giving them the opportunity to return it, (of course, don't give them any of your personal information!). But you may be able to find a way to communicate with them anonymously via a 3rd party phone or something to see what can be done.
    You will be happy to know that your device and its contents cannot be accessed by the thief, and if you don't care for tracking it, you also can also Erase all of your personal information from the device. This does not remove the Activation Lock, so they still won't be able to use it for anything.....
    Sorry for your troubles,
    GB

  • Restore from time machine does not list all my backups.  I know they exist but there dates are not present on the restore list.  Any help appreciated.

    Restore from time machine does not list all my backups.  I know they exist but their dates are not present on the restore list.  Any help appreciated.  If I must use one of these older dates to restore, how do I then get the more current data off time machine?

    Ok, so am i correct in saying that the steps to fix are as follows.
    That's one option, but not what I meant by restoring in the time-travel view. The latter is what you get when you enter Time Machine.
    is the fresh install not going to be able to "see" the time machine backups that I have at the moment.
    It should, but sometimes people report that it fails. I'm not sure why that happens.

  • M8 140 Acct assgt 01 for order item 45041838 00003 does not exist

    Hi experts,
    when i am trying to create invoice from BAPI_INCOMINGINVOICE_CREATE ii am getting the following error meesage for multi account assignment for non service based  invoice ,service items.
    error message: M8 140 Acct assgt 01 for order item 45041838 00003 does not exist
    Please advice
    Thanks & Regards,
    Narasimha

    Hi,
    Please check the SAP note number : 810917.
    Regards,

  • HT5714 If a song is available for download in a pre order will it count towards single chart counts?

    If a song is available for download in a pre order will it count towards single chart counts?

    Apple has not released any information as to how any of their charts and features are calculated, so no one here will know.
    Regards.

  • [svn:fx-trunk] 11523: Fix return values for ASyncListView/setItemAt(), removeItemAt(): return failed items if they exist.

    Revision: 11523
    Author:   [email protected]
    Date:     2009-11-06 11:58:50 -0800 (Fri, 06 Nov 2009)
    Log Message:
    Fix return values for ASyncListView/setItemAt(),removeItemAt(): return failed items if they exist.
    QE notes:
    Doc notes:
    Bugs: sdk-24078
    Reviewer: Evtim
    Tests run: AsyncListView Mustella tests pass
    Is noteworthy for integration: no
    Ticket Links:
        http://bugs.adobe.com/jira/browse/sdk-24078
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/framework/src/mx/collections/AsyncListView.as

  • How to recover replaced photos? They exist in iPhoto last import though.

    HHow should I recover the pictures that I lost while replacing them? Though they exist in my iPhoto last import but I am not able to even enlarge them.

    WE need details
    What version of iphoto? Is OS X 10.7.5 correct? What has recently changed? What exactly do you mean by "replacing them"? Exactly step by step how were you doing that?
    Probably the solution is going to be to restore your backup from before you lost your photos by replacing them
    And if they are in "last import" then they are in an event in your library (unless you have been mucking around inside the iphoto library using the finder or "claning" software (which is not needed and should not be used) - select one in last import and show event to see where it is
    LN

  • Simple drum loops -- do they exist?

    Hi, folks!
    I'm looking for some simple, clean, consistent sounding drum loops that are versatile (pop, rock, country) for songwriting. Everything out there I've encountered is layered with colour, effects and is way too busy.
    Any suggestions? Many thanks...

    Thanks, Sam. After hours of searching, I finally found a solution: Drums on Demand. No added colour, clean beats, and large groups of loops, perfect for songwriting.

Maybe you are looking for

  • Export to Excel is not working for List View Web Part after filtering using Query String parameters in SharePoint 2010

    Hi,  I am filtering SharePoint list view web part based on Query string parameter and I am doing Export to Excel by using following code. <a href="#" onclick="javascript:window.location='../_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=0DC

  • HT3131 how can i run in clamshell without the power adapter plugged in?

    just what the question states..I dont want to have to always connect the power adapter. thanks

  • ASR9K bundle-ether question

    hi guys,I have a question need confirm,could some friends help me. the topology is like this 1 .does this portchannel support or not ,I mean ASR9001 side is router subinterface,C4500X side is SW trunk interface 2.if this portchannel is support,could

  • WLE Performance vs WLS

    We are finding that running our EJBs in WLE 5.1 is yeilding performance times that are twice as slow as we get running the same EJBs in WLS 5.1. Is there anyone out there who have delpoyed their EJBs in a WLE environment that can provide some perform

  • Tiger Freezing

    I've been using my iBook G4 since June, 2004, and never had any problems with the laptop freezing until I upgraded to Tiger OS X 10.4.4. I have Tiger installed on an external HD. I haven't used Tiger that much yet. The biggest problem I've noticed is