Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7064709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:52:03+00:00 2026-05-28T04:52:03+00:00

I am using a SP which takes around a minute to execute; any ideas

  • 0

I am using a SP which takes around a minute to execute; any ideas for optimisation? For indexing I am using is the accessCodeID, amount of data is around 20k,

 SELECT COUNT(tbAC.abGUID) AS total,
       tbAC.abGUID,
       tbAC.aVID,
       tb_tt.used,

FROM   tbAC
       INNER JOIN (SELECT COUNT(abGUID) AS used,
                          abGUID
                   FROM   tbAC AS tbAC_1
                   WHERE  ( batchGUID = @id )
                          AND ( aVID > 0 )
                          AND ( isVoided = 0 )
                          AND ( isCodeUsed = 1 )
                   GROUP  BY abGUID) AS tb_tt
         ON tbAC.abGUID = tb_tt.abGUID
       INNER JOIN tbV
         ON tbAC.aVID = tbV.vendorID
WHERE  ( tbAC.aVID > 0 )
       AND ( tbAC.batchGUID = @id )
       AND ( tbAC.isVoided = 0 )
       AND ( lowLevelNotified = 0 )
GROUP  BY tbAC.abGUID,
          tbAC.aVID,
          tb_tt.used,
          tbV.name,
          tbV.firstName,
          tbV.lastName,
          tbV.tel,
          tbV.email,
          tbV.contactName  

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:52:04+00:00Added an answer on May 28, 2026 at 4:52 am

    Assuming allocatedVendorID is functionally dependant on abGUID, try:

    SELECT sum(case when lowLevelNotified = 0 then 1 else 0 end) AS total,
           tbAccessCode.abGUID,
           tbAccessCode.allocatedVendorID,
           sum(case when isCodeUsed = 1 then 1 else 0 end) AS used,
           tbV.name,
           tbV.firstName,
           tbV.lastName,
           tbV.tel,
           tbV.email,
           tbV.contactName
    FROM   tbAccessCode
           INNER JOIN tbV
             ON tbAccessCode.allocatedVendorID = tbV.vendorID
    WHERE  ( tbAccessCode.allocatedVendorID > 0 )
           AND ( tbAccessCode.batchGUID = 'abc-def' )
           AND ( tbAccessCode.isVoided = 0 )
    GROUP  BY tbAccessCode.abGUID,
              tbAccessCode.allocatedVendorID,
              tbV.name,
              tbV.firstName,
              tbV.lastName,
              tbV.tel,
              tbV.email,
              tbV.contactName
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a generic system for reporting which takes data from a database view
How to call a function which takes two parameters using threading in C#? I
I'm using a flash rotating banner in my website which takes images and descriptions
Is there any external library using which one can edit and save XML files
I have an data transformation query which takes a long time to run on
I have a WCF service hosted in IIS which takes a long time (around
I am using some code which was originally taken from the Apple sample ViewTransitions
I'm sometimes confused to using which one of them, say I have a function
Friends, I like to know using which version of Android SDK we can develop
I am using statfs() which gives me the free blocks available to a non-superuser.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.