0

いくつかの重要なデータを取得するレポート タスクに取り組んでおり、続行するのにいくつかの問題があります。基本的には医療分野に属しており、全体のデータはいくつかのテーブルに分散されており、データベースのテーブル設計のアーキテクチャを変更することはできません。レポートを完成させるには、次の手順が必要です。

1- divide the whole report to several parts, for each parts retrieve data by using
several joins. (like for part A can be retrieved by this:
select a1.field1, a2.field2 from a1 left join a2 on a1.fieldA= a2.fieldA ) then I can
got all the data from part A.

2- the same things happened for part B
select b1.field1, b2.field2 from b1 left join b2 on b1.fieldB= b2.fieldB, then I also
get all the data from part B.

3- same case for part C, part D.....and so on.

それらを分割する理由は、各パーツに 8 つ以上の結合が必要なため (医療データは常に複雑です)、1 回の結合ですべてを完了することはできません (50 を超える結合では完了できません)。 ..)

その後、Spring Batch プログラムを実行して、パート A のすべてのデータとパート b、パート c のデータを最終的なレポート テーブルとして 1 つのテーブルに挿入します。問題は、すべてのパーツが同じ数の行を持つわけではないということです。つまり、パーツ A が 10 行を返し、パーツ b が 20 行を返す場合があります。各部分の時間条件は同じ (1 日) であり、変更できないため、これらの異なる部分のデータをすべて 1 つのテーブルに最小限のオーバーヘッドで格納するにはどうすればよいでしょうか。多くの重複をしたくありません。多大な助けに感謝します。

レイ

4

1 に答える 1

0

Looks to me like what you need are joins over the "data from part A", "data from part B" & "data from part C". Lets call them da, db & dc. It's perfectly alright that num rows in da/b/c are different. But as you're trying to put them all in a single table at the end, obviously there is some relation between them. Without better description of that relation it's not possible to provide a more concrete answer. So I'll just write my thoughts, which you might already know, but anyway...

Simplest way is to join results from your 3 [inner] queries in a higher level [outer] query.

select j.x, j.y, j.z
from (
   ' da join db join dc
) j;

If this is not possible (due to way too many joins as you said) then try one of these:

  1. Create 3 separate materialized views (one each for da, db & dc) and perform the join these views. Materialized is optional (i.e. you can use the "normal" views too), but it should improve the performance greatly if available in your DB.
  2. First run queries for da/b/c, fetch the data and put this data in intermediate tables. Run a join on those tables.

PS: If you want to run reports (many/frequent/large size) on some data then that data should be designed appropriately, else you'll run into heap of trouble in future.

If you want something more concrete, please post the relationship between da/b/c.

于 2012-11-08T16:20:00.203 に答える