Simple Order of Magnitude counts.. do they exist ?
668023Oct 30 2008 — edited Nov 2 2008I 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 ?