I am hoping to find how I can get the kb size of a result set in OracleDB. I am not an sysadmin, but often run queries that return over 100k rows and I would need to find a way to determine what is the total kb size. thank you
A:
Generally, you would replace your column list with a count(*)
to return the row count.
I'm not sure how well that would work on really complicated queries with many joins and such but, for simpler queries, it should be fine. Replace:
select a,b,c from t where a > 7;
with
select count(*) from t where a > 7;
That will give you the row count before you run the real query. Just keep in mind there's a chance the data may change between your count query and real query (hopefully not too much). Knowledge of the data properties will allow you to approximate kilobytes from row count.
paxdiablo
2009-09-11 13:42:06
+8
A:
In SQL*Plus:
SET AUTOTRACE ON
SELECT *
FROM emp
WHERE rownum <= 100;
27 recursive calls
0 db block gets
19 consistent gets
4 physical reads
0 redo size
**11451 bytes sent via SQL*Net to client**
314 bytes received via SQL*Net from client
8 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
100 rows processed
jva
2009-09-11 13:49:13
Wow, that's amazing. Autotrace actually *knew* that you were interested in bytes sent and marked the lines with asterisks? You'd think Oracle would at least fix the bug that caused the misalignment of numbers though. :-) +1 for a better answer than mine.
paxdiablo
2009-09-11 13:59:08
Thanks for the answer, indeed the autotrace is great. Still have one more issue - I use SQL Developer and it seems that there are some unreturned results (the ones that I need :().When I set autotrace ON and run the SELECT, I get the following results: Statistics685 recursive calls3 db block gets22744 consistent gets247 physical reads0 redo size0 workarea executions - multipass0 parse time cpu0 parse time elapsed0 frame signature mismatch2 execute countAny tips and tricks on how this can be further tuned to retrieve the required results?
shermy
2009-09-14 11:23:26
by the way, how can I get this <h3>formated</h3>
shermy
2009-09-14 11:24:22
Note that "bytes sent via SQL*Net to client" represents the total amount of traffic from the server to the client, which includes more than just the result set itself. e.g. SELECT null FROM DUAL; => 411 bytes sent via SQL*Net to client (tested on Oracle 11.1)
Jeffrey Kemp
2009-09-14 13:39:21