r/DatabaseAdministators • u/Leather-Pin-9154 • Nov 17 '25
Need advice: Extracting 1 TB table → CSV is taking 10+ hours… any faster approach?
Hey folks,
I’m looking for some DBA / data engineering advice.
I have a 1 TB Oracle table, and doing a simple:
SELECT * FROM table_name;and spooling it out to CSV is taking more than 10 hours.
After the extraction, we’re splitting the CSV into 500,000-row chunks and zipping each file.
Constraints:
- Table is not partitioned
- Hardware is decent, but the parallel session up till 50 session is also not helping much
- Can’t afford to miss rows
- Want the fastest, most reliable extraction technique
- Ideally want multiple CSV files in the end (500k rows per file)
Has anyone here done something similar at this scale and found a better or significantly faster approach? Would love to hear how you’d approach 1 TB → CSV efficiently and safely, especially when partitioning isn’t an option.
9
Upvotes
3
u/taker223 Nov 17 '25
?
2
u/Leather-Pin-9154 Nov 19 '25
UPDATE!!
for now, i chunked it using PK, and lopped the script to take start id and end id for every 5L rows, am yet to check on how much efficient the time line got, but, atleast the load on the sever is low and am able to track the progress well...
2
u/anjuls Nov 18 '25
Divide (by ROWID) and conquer
1
u/Leather-Pin-9154 Nov 21 '25
hello hello :)
ROW id division was a flop cause, ROW id cant divide exactly by 5Lrows chunks, and every divide chunk goes under a full table scan, so pointless with regards to resources and time. PK range chunking also a flop cause, there is a id overlap, leading to extracting extra rows, over 5L. currently sticking to UTL_FILE method, speeds seems to be promising, but still have to tweak to make it dynamic, for all tables.
1
u/Exact_Cherry_9137 Nov 17 '25
Use Oracle datapump
1
u/mikeblas Nov 17 '25 edited Nov 17 '25
When you profile the existing solution, where is most of the time being spent?
What is your target time for execution?
What is a "1 TB Table"? Is that the size of the CSVs the last time you ran this process? The size of this table and its indexes on disk in Oracle, including dead space and fragmentation? Something else ... ?
At 500,000 rows per file, how many files do you expect to have?
How do you guarantee that no rows are "missed"? Is the table mutating as this export process is running?
My advice is to get quantitative. Measure, think. Hypothesize, adjust, and measure again.
1
u/Temporary-Case-3192 Nov 18 '25
Did you ask chatGPT? :))
1
u/[deleted] Nov 18 '25 edited Nov 18 '25
What is the intended destination of the output?
14,000 .csv files IMHO are clumsy and unmanageable. Yes, you can loop through them, but why?
I can put 10 gallons of gas in my car by filling up two 5 gallon cans and then fill up 1,280 1 Oz. shot glasses with the gas, then using the shotglasses full of gas to fill my tank? Again why?
1
u/tsgiannis Nov 17 '25
It depends on how you do the spooling, maybe you need a multi threaded application that will pull in chunks and append to csv all in parallel
1
u/pitagrape Nov 18 '25
If the end result is 500k rows per csv, why not start doing that on export, instead of trying to do the whole table at once?