IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Développement SQL Server Discussion :

Optimiser SP utilisée dans SSRS


Sujet :

Développement SQL Server

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Mars 2010
    Messages
    49
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mars 2010
    Messages : 49
    Points : 28
    Points
    28
    Par défaut Optimiser SP utilisée dans SSRS
    Salut a tous
    Je suis en train de faire un raport Kanban dans Sql builder 3.0 avec des donnes provenant de project server. J'arrive a afficher mon raport avec les filtres selectionnes mais le soucis vient du temps d'execution du raport, on dans l'ordre de 5-10 minutes, je suis donc en train de chercher comment l'optimiser, j'ai deja supprime quelques lignes mais mon raport mais toujours autant de temps pour s'afficher
    Donc mon raport est constitue d'un tableau reprenant les diverses phases et stage d'un workflow
    A chaque phase est associe plusieurs stage, j'ai donc delcare une liste dans laquelle j'ai ajoute mon tableau, ce qui me fait donc un nouveau tableau par phase.

    Ensuite en dessous de chaque phase, j'appelle un sous rapport ayant pour but de m'afficher les projets en cours ainsi que divers donnes lies a ce projet. Ici, j'ai du aller chercher les donnes dans une liste sharepoint sous format XML.
    Je sais que le probleme vient de la car pour afficher cette requete en lui passant les parametres, on a un temps d'execution tourant autour de 10s, or imaginons que mon sous rapport est appelle 60 fois sur mon rapport, voila ce qui explique ce temps d'execution un peu long
    Donc voici ma requete:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    USE [SPD15_SA_ProjectServer_Custom]
    GO
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[SP_Test]
    @StageNames          UNIQUEIDENTIFIER = NULL,
    @OwnerNames  Varchar(max)
     
    AS
    BEGIN
    SET NOCOUNT ON
           DECLARE       @LIST nvarchar(max) = 'Project Server Workflow Tasks'
           DECLARE @COL_Name nvarchar(max) ='nvarchar1'
           DECLARE @COL_DESCRIPTION nvarchar(max) ='ntext2'
           DECLARE @COL_DUE_DATE nvarchar(max)='datetime2'
           DECLARE @COL_PRCCOMPLETED nvarchar(max)='float1'
           DECLARE @COL_ASSIGNEDTO nvarchar(max)='nvarchar8'
           DECLARE @ProjectUID nvarchar(max)='nvarchar7'
           Declare @COL_OUTCOME nvarchar(max)='nvarchar6'
     
    ;WITH PhaseTable AS (                    SELECT
                  PRJ.ProjectUID, PRJ.ProjectName, PRJ.EnterpriseProjectTypeUID, EPT.ENTERPRISE_PROJECT_TYPE_NAME
                  , PRJ.ProjectOwnerResourceUID, PRJ.ProjectOwnerName
                  , PRJ.ProjectStartDate as PlannedStart, PRJ.ProjectFinishDate as PlannedFinish
                  , PRJ.[ISC Approval]
                  , PRJ.[DG/DEPT], PRJ.Program, PRJ.[IT Division], PRJ.[Project Short Description], PRJ.ProjectBaseline0Work BudgetWork, PRJ.[Project Status]
                  , STG.StageUID, STG.StageName, WS.StageOrder, STATUS.StageStateDescription, WS.StageEntryDate, WS.StageCompletionDate
                  , PHASE.PhaseUID, PHASE.PhaseName,WORKFLOW_ASSOCIATION_NAME AS workflowName,WORKFLOW_ASSOCIATION_UID as WorkflowUID
                         FROM
                  [SPD15_SA_ProjectServer_ProjectWebApp].[dbo].MSP_EpmProject_UserView PRJ
                  JOIN [SPD15_SA_ProjectServer_ProjectWebApp].[pub].[MSP_ENTERPRISE_PROJECT_TYPES] EPT on EPT.ENTERPRISE_PROJECT_TYPE_UID=PRJ.EnterpriseProjectTypeUID
                  LEFT JOIN [SPD15_SA_ProjectServer_ProjectWebApp].[dbo].[MSP_EpmWorkflowStatusInformation] WS on WS.ProjectUID=PRJ.ProjectUID
                  LEFT JOIN [SPD15_SA_ProjectServer_ProjectWebApp].[dbo].[MSP_EpmWorkflowStage] STG on STG.StageUID=WS.StageUID
                  LEFT JOIN [SPD15_SA_ProjectServer_ProjectWebApp].[dbo].[MSP_EpmWorkflowStatusType] STATUS on STATUS.StageStatusID=WS.StageStatus
                  LEFT JOIN [SPD15_SA_ProjectServer_ProjectWebApp].[dbo].[MSP_EpmWorkflowPhase] PHASE on PHASE.PhaseUID=STG.PhaseUID
                  WHERE  StageEntryDate IS NOT NULL AND StageCompletionDate IS NULL  AND WS.StageUID=@StageNames 
                  AND    @OwnerNames  like '%' + ISNULL( CAST(PRJ.ProjectOwnerResourceUID as nvarchar(max)), 'Not defined') + '%'
                  )
     
      , ProjectTable AS ( SELECT 
                  D.tp_Created as StartDate
                  , ISNULL(D.[tp_ColumnSet].value('(//*[local-name() = sql:variable("@COL_OUTCOME")])[1]', 'nvarchar(max)'),'Not Reviewed') as Outcome
                  ,D.[tp_ColumnSet].value('(//*[local-name() = sql:variable("@COL_Name")])[1]', 'nvarchar(max)') as TaskName
                  , D.[tp_ColumnSet].value('(//*[local-name() = sql:variable("@COL_DUE_DATE")])[1]', 'Date') as DueDate
                  ,D.[tp_ColumnSet].value('(//*[local-name() = sql:variable("@COL_ASSIGNEDTO")])[1]', 'nvarchar(max)') as AssignedTo,
                  Replace(right(D.[tp_ColumnSet].value('(//*[local-name() = sql:variable("@COL_DESCRIPTION")])[1]', 'nvarchar(max)'),36),' ','') ProjectUID 
           FROM 
                  [SPD15_PMIS].[dbo].[AllLists] L
                  JOIN [SPD15_PMIS].[dbo].[AllWebs] W on W.Id=L.tp_WebId
                  JOIN [SPD15_PMIS].[dbo].[AllUserData] D on D.[tp_ListId]=L.tp_ID
           where 
                  L.tp_Title = 'Project Server Workflow Tasks'
                  AND W.FullUrl like '%projects'
                  AND [tp_IsCurrentVersion]=1 
                  AND [tp_IsCurrent]=1
                  AND D.[tp_DeleteTransactionId]=0
           ) 
     
    , AggregateTable AS (
    Select T.ProjectUID
             ,max(createdDate) AS LastTaskDate
     
                  FROM(
    SELECT D.tp_Created as createdDate
                  ,Replace(right(D.[tp_ColumnSet].value('(//*[local-name() = sql:variable("@COL_DESCRIPTION")])[1]', 'nvarchar(max)'),36),' ','') ProjectUID 
           FROM 
                  [SPD15_PMIS].[dbo].[AllLists] L
                  JOIN [SPD15_PMIS].[dbo].[AllWebs] W on W.Id=L.tp_WebId
                  JOIN [SPD15_PMIS].[dbo].[AllUserData] D on D.[tp_ListId]=L.tp_ID
     
           where 
                  L.tp_Title = 'Project Server Workflow Tasks'
                  AND W.FullUrl like '%projects'
                  AND [tp_IsCurrentVersion]=1 
                  AND [tp_IsCurrent]=1
                  AND D.[tp_DeleteTransactionId]=0
                  ) as T
     
                  GROUP BY T.ProjectUID
                  )
     
      Select Outcome, PT.ProjectUID, StageName, PhaseUID, DueDate, AssignedTo, StageStateDescription,TaskName, StageUID,PHT.ProjectName, PT.StartDate
       FROM ProjectTable AS PT
      JOIN PhaseTable AS PHT
      on PT.ProjectUID = CAST(PHT.ProjectUID as nvarchar(max))
      JOIN AggregateTable AS AT  
     ON at.ProjectUID=PT.ProjectUID
    AND AT.LastTaskDate = PT.StartDate
     
     
    END
    Avez des idees de ce que je pourrais faire pour ameliorer cette requete ou mon rapport afin d'obtenir un temps d'attente acceptable?

    Edit: Apres plusieurs essais, le soucis vient clairement de mes requetes XML, une idee de la facon dont je pourrais gerer cela? Stocke les resultats dans une table, serait il plus efficace que d'appeler a chaque fois ma procedure stockee?

    Merci d'avance

  2. #2
    Rédacteur

    Avatar de SQLpro
    Homme Profil pro
    Expert bases de données / SQL / MS SQL Server / Postgresql
    Inscrit en
    Mai 2002
    Messages
    21 768
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Expert bases de données / SQL / MS SQL Server / Postgresql
    Secteur : Conseil

    Informations forums :
    Inscription : Mai 2002
    Messages : 21 768
    Points : 52 719
    Points
    52 719
    Billets dans le blog
    5
    Par défaut
    Le XML est par nature itératif et le SQL par nature ensembliste. Bref, vous prenez une fusée et lui demander de faire escale tous les 200 m....

    A +
    Frédéric Brouard - SQLpro - ARCHITECTE DE DONNÉES - expert SGBDR et langage SQL
    Le site sur les SGBD relationnels et le langage SQL: http://sqlpro.developpez.com/
    Blog SQL, SQL Server, SGBDR : http://blog.developpez.com/sqlpro
    Expert Microsoft SQL Server - M.V.P. (Most valuable Professional) MS Corp.
    Entreprise SQL SPOT : modélisation, conseils, audit, optimisation, formation...
    * * * * * Expertise SQL Server : http://mssqlserver.fr/ * * * * *

  3. #3
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Mars 2010
    Messages
    49
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mars 2010
    Messages : 49
    Points : 28
    Points
    28
    Par défaut
    Okay c'etait clairement le genre de reponse que je voulais obtenir, j'ai reussi a optimiser ma procedure stocke mais il y a toujours des elements prenant une plombe, donc je ne pourrais donc jamais obtenir les temps souhaites du au XML

    Merci pour votre retour

  4. #4
    Rédacteur

    Avatar de SQLpro
    Homme Profil pro
    Expert bases de données / SQL / MS SQL Server / Postgresql
    Inscrit en
    Mai 2002
    Messages
    21 768
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Expert bases de données / SQL / MS SQL Server / Postgresql
    Secteur : Conseil

    Informations forums :
    Inscription : Mai 2002
    Messages : 21 768
    Points : 52 719
    Points
    52 719
    Billets dans le blog
    5
    Par défaut
    Tentez d'indexer le XML, mais vue que vous faites appel à des fonctions génériques comme local-name() je ne suis pas sur que cela va améliorer les choses....

    A +
    Frédéric Brouard - SQLpro - ARCHITECTE DE DONNÉES - expert SGBDR et langage SQL
    Le site sur les SGBD relationnels et le langage SQL: http://sqlpro.developpez.com/
    Blog SQL, SQL Server, SGBDR : http://blog.developpez.com/sqlpro
    Expert Microsoft SQL Server - M.V.P. (Most valuable Professional) MS Corp.
    Entreprise SQL SPOT : modélisation, conseils, audit, optimisation, formation...
    * * * * * Expertise SQL Server : http://mssqlserver.fr/ * * * * *

Discussions similaires

  1. [2008R2] Code MDX dans un attribut pour utilisation dans SSRS
    Par scornille dans le forum SSAS
    Réponses: 0
    Dernier message: 21/04/2017, 18h45
  2. [2012] Code MDX dans un attribut pour utilisation dans SSRS
    Par scornille dans le forum SSRS
    Réponses: 1
    Dernier message: 21/04/2017, 18h43
  3. [2008R2] Utilisation Membre Calculé Cube dans SSRS via MDX
    Par dai.kaioh dans le forum SSRS
    Réponses: 0
    Dernier message: 21/10/2016, 10h45
  4. Optimisation d'une requête pour l'utiliser dans trigger
    Par Skandyx dans le forum Développement
    Réponses: 1
    Dernier message: 29/11/2012, 09h12
  5. Récupérer variables d'1 <form> et les utiliser dans X
    Par honeyz dans le forum XSL/XSLT/XPATH
    Réponses: 3
    Dernier message: 20/04/2006, 11h39

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo