473,326 Members | 2,126 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,326 software developers and data experts.

Want SQL executing fastre

Hi,
I have a problem in my below SQL,it took much time for getting the result(execution time is around 10 minutes).This sql contains many functions and also a DISTINCT keyword and its mandatory.So request you to please provide me solution for this. Indexes are exits and also I have analyzed all tables which been used inside this SQL.
I have removed the DISTINCT keyword its gave me result but its return duplicate records so i need it so please provide me the solution ASAP.
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT PC.ID,
  2.                 PC.IDTYPE,
  3.                 PC.CONSTROLEID,
  4.                 PC.CONSTROLEPRIMARYYN,
  5.                 CATMS.MAINCATID,
  6.                 CATMS.SUBCATID,
  7.                 MCAT.MAINCATDESC,
  8.                 SCAT.SUBCATDESC,
  9.                 B.BENID,
  10.                 B.BENDESC BENEFICIARY,
  11.                 P.PROJECTID,
  12.                 P.PROGRAMID,
  13.                 SUBSTR(DECODE(P.OPENCLOSEIND, 'C', 'C', 'O', 'O', NULL, 'P'),
  14.                        1,
  15.                        1) OPENCLOSEIND,
  16.                 DECODE(P.OPENCLOSEIND,
  17.                        NULL,
  18.                        'In Process',
  19.                        'C',
  20.                        'Closed',
  21.                        'O',
  22.                        'Open') STATUS_TYPE,
  23.                 PRJ_GETPROJECTSTATUS_STATUSID(P.PROJECTID) CURRENTSTATUSID,
  24.                 SL.STATUSID,
  25.                 SL.STSDESC STATUSDESC,
  26.                 TRUNC(PS.EFFDT) EFFDT,
  27.                 PS.ENDDT,
  28.                 SUBSTR((PRT.PROGTYSDESC || DECODE(P.FINLOCKYN,
  29.                                                   'Y',
  30.                                                   SUBSTR(P.APPRYEAR, 3, 2),
  31.                                                   '__') || P.PROJECTID),
  32.                        1,
  33.                        100) PROJECT_ID,
  34.                 PRT.PROGTYSDESC PROGTYSDESC,
  35.                 PRT.PROGTYDESC GRANTTYPE,
  36.                 P.PROJDESC PROJDESC,
  37.                 RI.NAME TRFSTAFF,
  38.                 PRJ_GETCOUNTRYNAME(P.LOCCNTRYID) PROJECTCOUNTRY,
  39.  
  40.                 SUBSTR(PRJ_GETPROJECTSTATUS(P.PROJECTID), 1, 100) CURRENTSTATUS,
  41.                 GETLASTPAYMENTDT(P.PROJECTID) LASTPAYMENT_DATE,
  42.                 GETREPORTEDDT(P.PROJECTID) REPORTEDDATE,
  43.                 PRJ_GETPROJECTCURRSTATUSDATE(P.PROJECTID) STATUSEFFDATE,
  44.                 PS.ENDDT STATUSENDDATE,
  45.                 P.APPRDT APPROVDATE,
  46.                 P.EFFDT PROJECTSTARTDATE,
  47.                 P.ENDDT PROJECTENDDATE,
  48.                 DECODE(P.FINLOCKYN, 'Y', PRJ_GETAWARDAMOUNT(P.PROJECTID), 0) TRFAWARD,
  49.                 SUBSTR(PROJECTINVOLVEMENT(PC.CONSTROLEPRIMARYYN,
  50.                                           PC.FUNDINGYN),
  51.                        1,
  52.                        200) INVOLVEMENT,
  53.                 CR.CONSTROLEDESC CONST_ROLE,
  54.                 CT.CONSTTYPEDESC CONST_TYPE,
  55.                 PRJ_FORMATNAMEFROMID(PC.ID, PC.IDTYPE, 'N') CONST_NAME,
  56.                 PRJ_GETDISTRICT(PC.ID, PC.IDTYPE, PC.EFFDT) DISTRICT,
  57.                 PRJ_GETCOUNTRY(PRJ_GETDISTRICT(PC.ID, PC.IDTYPE, PC.EFFDT),
  58.                                PC.ID,
  59.                                PC.IDTYPE) CONST_COUNTRY,
  60.                 PRJ_GETZONEID(PRJ_GETDISTRICT(PC.ID, PC.IDTYPE, PC.EFFDT)) ZONEID,
  61.                 PRJ_GETCONSTCASH(PC.PROJECTID,
  62.                                  PC.ID,
  63.                                  PC.IDTYPE,
  64.                                  PC.CONSTROLEID) CASHCOMMITTED,
  65.                 PRJ_GETCONSTDDF(PC.PROJECTID,
  66.                                 PC.ID,
  67.                                 PC.IDTYPE,
  68.                                 PC.CONSTROLEID) DDFCOMMITTED,
  69.                 PRJ_GETTOTALFUNDING(P.PROJECTID) TOTALFUNDING,
  70.                 CT.CONSTTYPEID NO_OF_VOLUNTEER,
  71.                 PRT.PROGTYID NO_TOTALS_IF_IG_3
  72.  
  73.   FROM PROJECT            P,
  74.        PROJECTCONSTITUENT PC,
  75.        PROGRAM            PR,
  76.        PROGRAMTYPE        PRT,
  77.        PROJECTSTATUS      PS,
  78.        PROGRAMPHASESTATUS PPS,
  79.        STATUSLIST         SL,
  80.        CONSTITUENTROLE    CR,
  81.        CONSTITUENTTYPE    CT,
  82.        PROJECTBENEFICIARY PB,
  83.        BENEFICIARY        B,
  84.        PROJECTCATEGORY    PCAT,
  85.        CATEGORYMAINSUB    CATMS,
  86.        MAINCATEGORY       MCAT,
  87.        SUBCATEGORY        SCAT,
  88.        ADMINUSERDATA      RI
  89.  
  90.  WHERE P.PROJECTID = PC.PROJECTID
  91.    AND P.PROGRAMID = PR.PROGRAMID
  92.    AND PR.PROGTYID = PRT.PROGTYID
  93.    AND P.PROJECTID = PS.PROJECTID
  94.    AND PS.PROGPHASESTATUSID = PPS.PROGPHASESTATUSID
  95.    AND PPS.STATUSID = SL.STATUSID
  96.    AND P.PROJECTID = PB.PROJECTID(+)
  97.    AND PB.BENID = B.BENID(+)
  98.    AND P.PROJECTID = PCAT.PROJECTID(+)
  99.    AND PCAT.CATID = CATMS.CATID(+)
  100.    AND CATMS.MAINCATID = MCAT.MAINCATID(+)
  101.    AND CATMS.SUBCATID = SCAT.SUBCATID(+)
  102.    AND PC.CONSTROLEID = CR.CONSTROLEID
  103.    AND PC.CONSTTYPEID = CT.CONSTTYPEID
  104.    AND P.ADMINUSERID = RI.ADMINUSERID(+)
  105.    AND CATMS.MAINCATID = 5
  106.    AND CATMS.SUBCATID = 12
  107.    AND P.OPENCLOSEIND = 'C'

Best Regards,
Kiran
Apr 30 '10 #1
1 1366
Same problem as with your last posting:
If you don't post the execution plan, noone will be able to help you
Apr 30 '10 #2

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

Similar topics

0
by: rvdw | last post by:
Hi All, I've a serious problem with executing stored procedures (SQL2000) from an Access db (version 97). After executing a stored procedure , msaccess hangs. The whole call to the procedure is...
0
by: Nick Coghlan | last post by:
Anyone playing with the CPython interpreter's new command line switch might have noticed that it only works with top-level modules (i.e. scripts that are directly on sys.path). If the script is...
15
by: Nick Coghlan | last post by:
Python 2.4's -m command line switch only works for modules directly on sys.path. Trying to use it with modules inside packages will fail with a "Module not found" error. This PEP aims to fix that...
7
by: Brian Burgess | last post by:
Hi all, Anyone know of any special issues with Server.Execute? Specifically for me it simply is not executing ... the server does not transfer to the page specified. The calling ASP just...
10
by: Heiko Pliefke | last post by:
Hi NG! I wrote a stored procedure which at first deletes 100.000 rows and then inserts 100.000 new rows. There is a huge difference between executing this SP in the query-analyzer (runtime...
7
by: Jibey | last post by:
Hello: I'm facing a very strange problem. When I run my Web application in Visual Studio.NET the Page_Load event is not executing. Other events like a Button_Click are executing. It doesn't...
7
by: Edward Yang | last post by:
In my test, I have two web applications app1 and app2, and I configure them as follows in IIS: $/comboapps |--web.config |--bin | app1.dll | app2.dll |--app1 | form1.aspx
0
by: whidbeywave | last post by:
Hello all, Help me understanding this situtation. While debugging a scenario for error 403.9 on IIS/XP Pro, I added two counters to perfmon app.I saw at some point of time Session Active =0 , but...
7
by: CodeGrommet | last post by:
I'm testing out the system() command. I coded the following. How can I output the results into the given output file? Your help will be appreciated. /* system example : DIR */ //code based...
3
by: =?Utf-8?B?U2hhbG9t?= | last post by:
I have installed iis 7 on my win vista home premium Sony Vaio laptop, and then tried executing downloaded sample working asp scripts in the wwwroot directory to try out. The first asp script...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.