How to extract Tasy data without slowing down the production database
A query that runs in two seconds in testing can slow billing down at ten in the morning. What changes when extraction is done right, and the checklist to agree with the DBA.
The Tasy database is the same one serving registration, the emergency department, pharmacy and billing. When someone asks to extract Tasy data for a BI, IT's first concern is fair: a badly written query at the wrong time slows the system for the people treating patients. It is possible to pull everything management needs without that effect, as long as extraction follows a few rules.
Where extraction weighs
A SELECT in Oracle does not lock the rows it reads, so the risk is not freezing patient care. The risk is consumption: CPU, disk reads, memory and temporary space competing with normal use. The cases we see most:
- Reading the whole table on every run. CONTA_PACIENTE_RESUMO and PROCEDIMENTO_PACIENTE pile up tens of millions of rows in a few years. Reading all of it every hour to refresh a dashboard is the fastest way to make the database heavy.
- A function on the filtered column.
WHERE TRUNC(dt_entrada) = TRUNC(SYSDATE)prevents the date index from being used. The equivalentWHERE dt_entrada >= TRUNC(SYSDATE) AND dt_entrada < TRUNC(SYSDATE) + 1uses it. - Large joins inside Tasy. Joining account, summary, procedure, payer and unit in one aggregated query forces Oracle to build the whole result before returning the first row. Bringing the tables over and joining at the destination is usually lighter on the hospital.
- Long queries during working hours. A 40-minute query at ten in the morning competes with billing closing accounts. The same query at five in the morning bothers nobody.
- ORA-01555 (snapshot too old). Very long queries may fail when Oracle can no longer rebuild the data as it was when the query started. Splitting the load into smaller slices solves it.
The usual options
| Approach | How it works | Load on Tasy | Note |
|---|---|---|---|
| BI querying Tasy directly | Every dashboard opening fires queries at the production database | High and unpredictable | The approach IT complains about most |
| Exported reports | Someone runs a report and saves it as a spreadsheet | Low, but manual | Delays, versions and typing errors |
| Read replica or standby | A copy of the database takes the queries | Almost none | Requires licensing and infrastructure; not every hospital has it |
| Incremental extraction to an intermediate database | A routine brings only what changed and writes it elsewhere | Low and predictable | The model we recommend and that Clic Health uses |
When the hospital already has a read replica, it is the best source for extraction. When it does not, well-configured incremental extraction comes close to the same result.
The rules of light extraction
- Read-only database user, with SELECT only on the tables and views needed. No Tasy application user, no administrator, no write permission.
- Read-only session. Besides the user, the session itself should be opened read-only. If someone mistakenly puts a write command in a query, the database refuses it.
- Incremental for transaction tables. Encounters, accounts, procedures and surgeries have DT_ATUALIZACAO. The load brings only rows changed since the last run, with a margin of a few minutes so it does not miss transactions that committed late. The reason is in Tasy incremental loads.
- Full loads only for small master tables. Payers, units, cost centers and items can come in full once a day, before dawn.
- Frequency by how the information is used. Encounters and accounts every 5 minutes make sense for the emergency department and bed management. Accounting and costing do not change by the hour; once or twice a day is enough.
- A limit per run. A cap on rows per run and a maximum time per query keep a filter mistake from becoming a read of years of history in the middle of the day.
- Initial load in slices. Five years of history come in month by month, at night and over the weekend, not in a single query.
- Periodic re-read of a recent window. Rows deleted in Tasy never show up in an incremental load. Re-reading, for example, the last 7 days every night and the last 3 months once a week keeps the destination equal to the source.
- A log of every run. How long it took, how many rows it brought and whether it failed. Without that log, the first sign of trouble is an outdated dashboard.
What to agree with the DBA
The hospital's DBA (or whoever runs the database at the infrastructure provider) has to approve and follow the extraction. Bring to the conversation:
- the list of tables and views to be read and the reason for each one;
- the user to be created, its permissions, and confirmation that it is read-only;
- the frequencies and schedules of the loads, and when the historical load will run;
- the expected volume per run after the initial load;
- the existing indexes on the date columns used as filters. Do not create indexes on Tasy tables on your own; if one is missing, the decision belongs to the DBA, after hearing the vendor;
- the network path: where extraction starts, where it goes and through which port;
- how to switch extraction off in an emergency.
With this documented, IT knows exactly what is running on the database and can measure the effect.
How DataClic does it
DataClic is the program that reads Tasy for Clic Health and the other Clic solutions. It runs on a server at the hospital and follows the rules above by default:
- opens the Oracle session in read-only mode and refuses users with administrator privileges;
- brings transactions incrementally, with a default 15-minute margin over the last watermark;
- re-reads 7 days every night and 3 months every Sunday, to reflect deletions and corrections;
- caps each run at 5 million rows and each query at 60 minutes;
- loads master tables once a day, at 5 a.m.;
- does not let the patient's name, national ID, health card, address, phone, e-mail or date of birth leave Tasy; patients travel as a code;
- opens no inbound port at the hospital: it only makes outbound HTTPS connections.
Read rules are digitally signed and verified by DataClic before running. A package from another hospital, or one altered on the way, is refused. Details are in security and in Tasy integration and refresh.
Signs that the current extraction is weighing
- Complaints about Tasy being slow, always at the same time of day.
- BI queries at the top of the database's heaviest sessions.
- Dashboards that take minutes to open, because they query Tasy on the spot.
- Loads failing with ORA-01555 or running out of temporary space.
- Nobody can say how many queries the BI runs on the database per day.
If two or more apply, review the extraction before adding dashboards.
Who writes this
Domínio has worked for more than 20 years with hospitals that run Tasy and wrote the read rules of the Clic Health standard from that experience. If your IT team wants to review an existing extraction, talk to us on WhatsApp or at comercial@dominiocontabil.com.br.
Related questions
Can a SELECT freeze Tasy?
In Oracle, a read does not lock rows for those who are writing. The effect of a heavy query is to consume server resources and make everyone slower, not to freeze screens.
Do we need a database replica?
It is not mandatory. It is the best option when it exists. Without a replica, incremental extraction with well-defined schedules and limits has a low and predictable load.
What is the ideal refresh frequency?
It depends on the use. Emergency and bed dashboards call for minutes; billing, a few times an hour; accounting and costing, once or twice a day.
Can the BI write to Tasy?
It should not. Extraction for BI is read-only, both in the user and in the session.
Written by the Domínio team behind Clic Health: accountants, controllers and developers with more than 20 years of work with hospitals that run Tasy. Have a question about Tasy? Talk to us on WhatsApp.