473,385 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to improve performance on query

Please suggest me a better alternative for this query to reduce execution time.

Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT claim_number,
  2.                 status,
  3.                 date_received,
  4.                 pay_amount
  5.   FROM (SELECT c.claim_number,
  6.                c.status,
  7.                c.date_received,
  8.                p.pay_amount
  9.           FROM claims.ardis_active_groups aag,
  10.                claims.claim c,
  11.                claims.payment p
  12.          WHERE     aag.GROUP_ID = c.GROUP_ID
  13.                AND c.claim_seq = p.claim_seq
  14.                AND c.status IN ('O', 'C')
  15.         UNION
  16.         SELECT c.claim_number,
  17.                c.status,
  18.                c.date_received,
  19.                p.pay_amount
  20.           FROM claims.claim c, claims.payment p, claims.service_provider sp
  21.          WHERE     c.claim_seq = p.claim_seq
  22.                AND c.service_provider_seq = sp.service_provider_seq
  23.                AND c.status IN ('O', 'C')
  24.         UNION
  25.         SELECT c.claim_number,
  26.                c.status,
  27.                c.date_received,
  28.                p.pay_amount
  29.           FROM claims.claim c,
  30.                claims.payment p,
  31.                claims.claim_profile cp,
  32.                gman.mem_evd_address@ardis mea
  33.          WHERE     c.claim_seq = p.claim_seq
  34.                AND c.member_claim_profile_seq = cp.claim_profile_seq
  35.                AND cp.ardis_member_seq = mea.mem_evd_seq
  36.                AND c.status IN ('O', 'C'));


No of rows in each table:

claim_profile: 10,254,590
mem_evd_address: 6,343,539
claim:5121867
payment:3051578
service_provider:773468
aag:4750
Jul 17 '11 #1
6 3395
debasisdas
8,127 Expert 4TB
What about posting table structure and relations between them.
Jul 18 '11 #2
Expand|Select|Wrap|Line Numbers
  1. Alter table claims.claim
  2.  drop primary key cascade;
  3.  
  4. drop table claims.claim cascade constraints;
  5.  
  6. create table claims.claim
  7. (
  8.   claim_form_seq                  number(18),
  9.   claim_number                    varchar2(40 byte),
  10.   correspondence_required         varchar2(1 byte),
  11.   status                          varchar2(3 byte),
  12.   total_charge                    number(9,2),
  13.   group_id                        varchar2(10 byte),
  14.   claim_seq                       number(18) constraint sys_c001506 not null,
  15.   special_handling_rule_seq       number(18),
  16.   member_claim_profile_seq        number(18),
  17.   patient_claim_profile_seq       number(18),
  18.   aob                             varchar2(1 byte),
  19.   payee                           varchar2(1 byte),
  20.   group_name                      varchar2(80 byte),
  21.   policy_number                   varchar2(20 byte),
  22.   claim_qualify_message           varchar2(10 byte),
  23.   plan_type                       varchar2(4 byte),
  24.   last_updated_user               varchar2(40 byte),
  25.   last_updated_date               date,
  26.   create_date                     date,
  27.   create_user                     varchar2(40 byte),
  28.   accident_indicator              varchar2(1 byte),
  29.   xray                            varchar2(1 byte),
  30.   user_comments                   clob,
  31.   date_received                   date,
  32.   work_comp                       varchar2(1 byte),
  33.   provider_seq                    number(18),
  34.   service_provider_seq            number(18),
  35.   generation                      number(18),
  36.   closed_date                     date,
  37.   recent_delay_notice_sent_ts     date,
  38.   pe_number                       varchar2(5 byte),
  39.   correspondence_resend           varchar2(1 byte),
  40.   claim_form_provdr_zip_override  varchar2(3 byte)
  41. )
  42. lob (user_comments) store as (
  43.   tablespace claims_5m
  44.   enable       storage in row
  45.   chunk       8192
  46.   retention
  47.   nocache
  48.   logging
  49.   index       (
  50.         tablespace claims_5m
  51.         storage    (
  52.                     initial          5m
  53.                     next             5m
  54.                     minextents       1
  55.                     maxextents       unlimited
  56.                     pctincrease      0
  57.                     freelists        1
  58.                     freelist groups  1
  59.                     buffer_pool      default
  60.                    ))
  61.       storage    (
  62.                   initial          5m
  63.                   next             5m
  64.                   minextents       1
  65.                   maxextents       unlimited
  66.                   pctincrease      0
  67.                   freelists        1
  68.                   freelist groups  1
  69.                   buffer_pool      default
  70.                  ))
  71. tablespace claims_100m
  72. pctused    40
  73. pctfree    10
  74. initrans   1
  75. maxtrans   255
  76. storage    (
  77.             initial          160k
  78.             next             100m
  79.             minextents       1
  80.             maxextents       unlimited
  81.             pctincrease      0
  82.             freelists        1
  83.             freelist groups  1
  84.             buffer_pool      default
  85.            )
  86. logging 
  87. nocompress 
  88. nocache
  89. noparallel
  90. nomonitoring;
  91.  
  92.  
  93. create unique index claims.claims_claimnum_idx on claims.claim
  94. (claim_number)
  95. logging
  96. tablespace claims_5m_bk32_idx
  97. pctfree    10
  98. initrans   2
  99. maxtrans   255
  100. storage    (
  101.             initial          5m
  102.             next             5m
  103.             minextents       1
  104.             maxextents       unlimited
  105.             pctincrease      0
  106.             freelists        1
  107.             freelist groups  1
  108.             buffer_pool      default
  109.            )
  110. noparallel;
  111.  
  112.  
  113. create index claims.claims_groupid_idx on claims.claim
  114. (group_id)
  115. logging
  116. tablespace claims_5m_bk32_idx
  117. pctfree    10
  118. initrans   2
  119. maxtrans   255
  120. storage    (
  121.             initial          5m
  122.             next             5m
  123.             minextents       1
  124.             maxextents       unlimited
  125.             pctincrease      0
  126.             freelists        1
  127.             freelist groups  1
  128.             buffer_pool      default
  129.            )
  130. noparallel;
  131.  
  132. alter index claims.claims_groupid_idx
  133.   monitoring usage;
  134.  
  135.  
  136. create unique index claims.claims_idx_4 on claims.claim
  137. (patient_claim_profile_seq)
  138. logging
  139. tablespace claims_5m_idx
  140. pctfree    10
  141. initrans   2
  142. maxtrans   255
  143. storage    (
  144.             initial          5m
  145.             next             5m
  146.             minextents       1
  147.             maxextents       unlimited
  148.             pctincrease      0
  149.             freelists        1
  150.             freelist groups  1
  151.             buffer_pool      default
  152.            )
  153. noparallel;
  154.  
  155.  
  156. create unique index claims.claim_idx_3 on claims.claim
  157. (member_claim_profile_seq)
  158. logging
  159. tablespace claims_5m_bk32_idx
  160. pctfree    10
  161. initrans   2
  162. maxtrans   255
  163. storage    (
  164.             initial          5m
  165.             next             5m
  166.             minextents       1
  167.             maxextents       unlimited
  168.             pctincrease      0
  169.             freelists        1
  170.             freelist groups  1
  171.             buffer_pool      default
  172.            )
  173. noparallel;
  174.  
  175.  
  176. create index claims.claim_idx_5 on claims.claim
  177. (claim_form_seq)
  178. logging
  179. tablespace claims_5m_bk32_idx
  180. pctfree    10
  181. initrans   2
  182. maxtrans   255
  183. storage    (
  184.             initial          5m
  185.             next             5m
  186.             minextents       1
  187.             maxextents       unlimited
  188.             pctincrease      0
  189.             freelists        1
  190.             freelist groups  1
  191.             buffer_pool      default
  192.            )
  193. noparallel;
  194.  
  195.  
  196. create index claims.claim_idx_6 on claims.claim
  197. (last_updated_date, last_updated_user, status)
  198. logging
  199. tablespace claims_5m
  200. pctfree    10
  201. initrans   2
  202. maxtrans   255
  203. storage    (
  204.             initial          5m
  205.             next             5m
  206.             minextents       1
  207.             maxextents       unlimited
  208.             pctincrease      0
  209.             freelists        1
  210.             freelist groups  1
  211.             buffer_pool      default
  212.            )
  213. noparallel;
  214.  
  215.  
  216. create index claims.claim_idx_7 on claims.claim
  217. (service_provider_seq)
  218. logging
  219. tablespace claims_5m_bk32_idx
  220. pctfree    10
  221. initrans   2
  222. maxtrans   255
  223. storage    (
  224.             initial          5m
  225.             next             5m
  226.             minextents       1
  227.             maxextents       unlimited
  228.             pctincrease      0
  229.             freelists        1
  230.             freelist groups  1
  231.             buffer_pool      default
  232.            )
  233. noparallel;
  234.  
  235.  
  236. create index claims.claim_prov_seq_idx1 on claims.claim
  237. (provider_seq)
  238. logging
  239. tablespace claims_256k
  240. pctfree    10
  241. initrans   2
  242. maxtrans   255
  243. storage    (
  244.             initial          256k
  245.             next             256k
  246.             minextents       1
  247.             maxextents       unlimited
  248.             pctincrease      0
  249.             freelists        1
  250.             freelist groups  1
  251.             buffer_pool      default
  252.            )
  253. noparallel;
  254.  
  255.  
  256. create unique index claims.sys_c001507 on claims.claim
  257. (claim_seq)
  258. logging
  259. tablespace claims_5m_bk32_idx
  260. pctfree    10
  261. initrans   2
  262. maxtrans   255
  263. storage    (
  264.             initial          5m
  265.             next             5m
  266.             minextents       1
  267.             maxextents       unlimited
  268.             pctincrease      0
  269.             freelists        1
  270.             freelist groups  1
  271.             buffer_pool      default
  272.            )
  273. noparallel;
  274.  
  275.  
  276. alter table claims.claim add (
  277.   constraint ck_accident_indicator
  278.   check (accident_indicator in ('y', 'n')),
  279.   constraint ck_xray
  280.   check (xray in ('y', 'n')),
  281.   constraint sys_c002004
  282.   check ("claim_number" is not null),
  283.   constraint sys_c002325
  284.   check ("generation" is not null),
  285.   constraint sys_c001507
  286.   primary key
  287.   (claim_seq)
  288.   using index
  289.     tablespace claims_5m_bk32_idx
  290.     pctfree    10
  291.     initrans   2
  292.     maxtrans   255
  293.     storage    (
  294.                 initial          5m
  295.                 next             5m
  296.                 minextents       1
  297.                 maxextents       unlimited
  298.                 pctincrease      0
  299.                 freelists        1
  300.                 freelist groups  1
  301.                ),
  302.   constraint claim_number_unique
  303.   unique (claim_number)
  304.   using index claims.claims_claimnum_idx);
  305.  
  306. alter table claims.claim add (
  307.   constraint fk_claim_1 
  308.   foreign key (provider_seq) 
  309.   references claims.provider (provider_seq),
  310.   constraint fk_claim_2 
  311.   foreign key (service_provider_seq) 
  312.   references claims.service_provider (service_provider_seq),
  313.   constraint fk_claim_member_cps 
  314.   foreign key (member_claim_profile_seq) 
  315.   references claims.claim_profile (claim_profile_seq),
  316.   constraint fk_claim_patient_cps 
  317.   foreign key (patient_claim_profile_seq) 
  318.   references claims.claim_profile (claim_profile_seq));
  319.  
  320. audit alter on claims.claim by access whenever successful;
  321. audit alter on claims.claim by access whenever not successful;
  322. audit audit on claims.claim by access whenever successful;
  323. audit audit on claims.claim by access whenever not successful;
  324. audit delete on claims.claim by session whenever not successful;
  325. audit grant on claims.claim by access whenever successful;
  326. audit grant on claims.claim by access whenever not successful;
  327. audit index on claims.claim by access whenever successful;
  328. audit index on claims.claim by access whenever not successful;
  329. audit insert on claims.claim by session whenever not successful;
  330. audit select on claims.claim by session whenever not successful;
  331. audit update on claims.claim by session whenever not successful;
  332.  
  333. grant delete, insert, select, update on claims.claim to claims_role;
  334.  
  335. grant delete, insert, select, update on claims.claim to claims_user;
  336.  
  337. grant select on claims.claim to crystal_role;
  338.  
  339. grant select on claims.claim to db_link;
  340.  
  341. grant select on claims.claim to grins_view_only;
  342.  
  343. grant delete, insert, select, update on claims.claim to ops$gman;
Jul 18 '11 #3
rski
700 Expert 512MB
Remove DISTINCT clause, you don't need it because you use UNION and UNION removes duplicates.
After that check if it is enough for you. If you want additional tuning, post here execution plan.
Do you execute many insert/update/delete statements on these tables?
Jul 18 '11 #4
I've already removed distinct but the query is still running very slow.

Explain Plan for the Query:

Explain plan for the query:

SELECT STATEMENT FIRST_ROWS Cost: 3.14101209224186944E23 Cardinality: 1.01672310708368992E27 IO Cost: 3.14101209224186944E23

31 SORT UNIQUE NOSORT Cost: 3.14101209224186944E23 Cardinality: 1.01672310708368992E27 IO Cost: 3.14101209224186944E23

30 VIEW CLAIMS. Cost: 3.14101209224186944E23 Cardinality: 1.01672310708368992E27

29 SORT UNIQUE Cost: 3.14101209224186944E23 Cardinality: 1.01672310708368992E27 IO Cost: 927,161,786,876,889

28 UNION-ALL
8 FILTER (:Z='O' OR :Z='C') AND :Z=:Z AND :Z=:Z

7 MERGE JOIN CARTESIAN Cost: 927,156,181,244,344 Cardinality: 2.98664713188915008E18 IO Cost: 927,156,181,244,344

4 MERGE JOIN CARTESIAN Cost: 333,639,604 Cardinality: 583,116,885,286 IO Cost: 333,639,604

1 REMOTE SERIAL_FROM_REMOTE ARDIS.JP.CORP SELECT 0 FROM "GMAN"."DENTAL_ACTIVE_GROUPS_VIEW" "DENTAL_ACTIVE_GROUPS_VIEW" Cost: 1,702 Cardinality: 191,087

3 BUFFER SORT Cost: 333,637,902 Cardinality: 3,051,578 IO Cost: 333,637,902

2 INDEX FAST FULL SCAN CLAIMS.PK_PAYMENT [Analyzed] Cost: 1,746 Cardinality: 3,051,578 IO Cost: 1,746

6 BUFFER SORT Cost: 927,156,181,242,598 Cardinality: 5,121,867 IO Cost: 927,156,181,242,598

5 INDEX FAST FULL SCAN CLAIMS.SYS_C001507 [Analyzed] Cost: 1,590 Cardinality: 5,121,867 IO Cost: 1,590

16 FILTER (:Z='O' OR :Z='C') AND :Z=:Z AND :Z=:Z

15 MERGE JOIN CARTESIAN Cost: 3,752,875,063,156,960 Cardinality: 1.20891320906605008E19 IO Cost: 3,752,875,063,156,960

12 MERGE JOIN CARTESIAN Cost: 1,350,475,598 Cardinality: 2,360,297,932,504 IO Cost: 1,350,475,598

9 INDEX FAST FULL SCAN CLAIMS.PK_SERVICE_PROVIDER [Analyzed] Cost: 470 Cardinality: 773,468 IO Cost: 470

11 BUFFER SORT Cost: 1,350,475,128 Cardinality: 3,051,578 IO Cost: 1,350,475,128

10 INDEX FAST FULL SCAN CLAIMS.PK_PAYMENT [Analyzed] Cost: 1,746 Cardinality: 3,051,578 IO Cost: 1,746

14 BUFFER SORT Cost: 3,752,875,063,155,210 Cardinality: 5,121,867 IO Cost: 3,752,875,063,155,210

13 INDEX FAST FULL SCAN CLAIMS.SYS_C001507 [Analyzed] Cost: 1,590 Cardinality: 5,121,867 IO Cost: 1,590

27 FILTER (:Z='O' OR :Z='C') AND :Z=:Z AND :Z=:Z AND :Z=:Z

26 MERGE JOIN CARTESIAN Cost: 3.14101204544137984E23 Cardinality: 1.01672309200790992E27 IO Cost: 3.14101204544137984E23

23 MERGE JOIN CARTESIAN Cost: 30,778,919,522,550,298 Cardinality: 9.91480977794249088E19 IO Cost: 30,778,919,522,550,298

20 MERGE JOIN CARTESIAN Cost: 11,075,828,532 Cardinality: 19,357,804,054,542 IO Cost: 11,075,828,532

17 REMOTE SERIAL_FROM_REMOTE ARDIS.JP.CORP SELECT 0 FROM "GMAN"."MEM_EVD_ADDRESS" "MEA" Cost: 9,438 Cardinality: 6,343,539

19 BUFFER SORT Cost: 11,075,819,094 Cardinality: 3,051,578 IO Cost: 11,075,819,094

18 INDEX FAST FULL SCAN CLAIMS.PK_PAYMENT [Analyzed] Cost: 1,746 Cardinality: 3,051,578 IO Cost: 1,746

22 BUFFER SORT Cost: 30,778,919,522,548,602 Cardinality: 5,121,867 IO Cost: 30,778,919,522,548,602

21 INDEX FAST FULL SCAN CLAIMS.SYS_C001507 [Analyzed] Cost: 1,590 Cardinality: 5,121,867 IO Cost: 1,590

25 BUFFER SORT Cost: 3.14101204544137984E23 Cardinality: 10,254,590 IO Cost: 3.14101204544137984E23

24 INDEX FAST FULL SCAN CLAIMS.PK_CLAIM_PROFILE [Analyzed] Cost: 3,168 Cardinality: 10,254,590 IO Cost: 3,168
Jul 18 '11 #5
Can anybody tell me how do i do partitioning for my query since the data is very huge
Jul 18 '11 #6
Please let me know how can i improve performance of my query.

Do you think partition would work since there are millions of rows in each table
Jul 19 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Dave Theese | last post by:
Hello all, I'm in a poition of trying to justify use of the STL from a performance perspective. As a starting point, can anyone cite any benchmarks comparing vectors to plain old...
13
by: bjarne | last post by:
Willy Denoyette wrote; > ... it > was not the intention of StrousTrup to the achieve the level of efficiency > of C when he invented C++, ... Ahmmm. It was my aim to match the performance...
0
by: Bijesh | last post by:
Hi All, I'm using the .NET performance counters to calculate the network utilization. But this value exceeds 100%. In most of the cases, it is very similar to the one shown in the task-manager....
7
by: James | last post by:
Hi Has anybody had any experience of ASP.Net performance counters not updating. In the performance monitor application when I try to add the groups ASP.NET and ASP.NET Applications the...
0
by: bimalendug | last post by:
Hi All, I'm using the .NET performance counters to calculate the network utilization. But this value exceeds 100%. In most of the cases, it is very similar to the one shown in the task-manager....
18
by: Rune B | last post by:
Hi Group I was considering using a Generic Dictionary<> as a value container inside my business objects, for the reason of keeping track of fields changed or added and so on. - But how...
5
by: sp | last post by:
Hello I have a problem with the refresh performance in datagrid – when datagrid is being shown it is so slow that I can see one by one cells is drawn -datagrid contains about 35x40 of...
7
by: Michael D. Ober | last post by:
When calling Enqueue, the internal array may need to be reallocated. My question is by how much? In the old MFC array classes, you could tell MFC how many additional elements to add to the array...
8
by: NAdir | last post by:
Hi, thank you for your help. My VB.Net application contains a document that the user can refresh at any time. The refresh works fine and needs to loop through few datatables (hundreds of rows)....
12
by: Ilyas | last post by:
Hi all I have an application which brings back 1000 records from a sql server database. Under the local asp.net development server provided with Visual Studio 2008, it takes about 1.8 seconds ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.