First of all, why do you need a CSV file with all cases' audit history records while you have the SQL table/s?
Please be in mind the work history table/s would contain ALL audit history records of cases regardless of its statuses, excluding that are purged and so usually it would be gigantic table/s. My first recommendation is do not export the case audit history contents to CSV.
If still needed, you shall touch base with your DBA to export the contents of Work History tables of relevant cases, by making sure the query is filtered with indexed columns to provide the limited number of records to avoid slowness/outage. In fact the DB tools such as SQL Squirrel and SQL developers does provide this feature to export the table contents to csv and pdf. Importantly, do the export outside the applications' active hours.