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

  • Home
  • SEARCH
  • 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 3634540
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:47:30+00:00 2026-05-19T00:47:30+00:00

SELECT projectID, urlID, COUNT(1) AS totalClicks, projectPage, (SELECT COUNT(1) FROM tblStatSessionRoutes, tblStatSessions WHERE tblStatSessionRoutes.statSessionID

  • 0
   SELECT projectID, urlID, COUNT(1) AS totalClicks, projectPage,
   (SELECT COUNT(1)
     FROM   tblStatSessionRoutes, tblStatSessions
     WHERE  tblStatSessionRoutes.statSessionID = tblStatSessions.ID
     AND    tblStatSessions.projectID = tblAdClicks.projectID
     AND    (tblStatSessionRoutes.leftPageID = tblAdClicks.projectPage OR
           tblStatSessionRoutes.rightPageID = tblAdClicks.projectPage)) AS totalViews
   FROM   tblAdClicks
   WHERE  projectID IN (SELECT projectID FROM tblProjects WHERE userID = 5)
   GROUP  BY projectID, urlID, projectPage
   ORDER  BY CASE projectID
          WHEN 170 THEN
           1
          ELSE
           0
      END, projectID

This is by no means an especially complex query, but because the database is normalised to a good level, and we are dealing with a significant amount of data, this query can be quite slow for the user.

Does anyone have tips on how to improve the speed of it? If I strategically denormalise parts of the database would this help? Will running it in a stored proc offer significant improvements?

The way I handle the data is efficient in my code, the bottleneck really is with this query.

Thanks!

  • 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-19T00:47:31+00:00Added an answer on May 19, 2026 at 12:47 am

    De-normalising your database should be a last resort since (to choose just one reason) you don’t want to encourage data inconsistencies which de-normalisation will allow.

    First thing is to see if you can get some clues from the query execution plan. It could be, for example, that your sub-selects are costing too much, and would be better done first into temp tables which you then JOIN in your main query.

    Also, if you see lots of table-scans, you could benefit from improved indexes.

    If you haven’t already, you should spend a few minutes re-formatting your query for readability. It’s amazing how often the obvious optimisation will jump out at you while doing this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$result = mysql_query(SELECT * FROM project ORDER BY projectid); while($row = mysql_fetch_array($result)) { return(array($row['projectid'],
function showFields($selClient) { $result = mysql_query(SELECT * FROM project WHERE projectid = $selClient); $values
this is my code function code_exists($code){ $code = mysql_real_escape_string($code); $code_exists = mysql_query(SELECT COUNT('url_id') FROM
IF NOT EXISTS(SELECT * FROM dbo.com_project_transaction_link WHERE pt_tr_transaction_id = @transactionId AND pt_pj_project_id = @projectId)
My Sql query is, Select CustomerName,ProjectID,ProjectDesc from dbo.projects The Output is: CustomerName ProjectID ProjectDesc
In T-SQL, you can do this: SELECT ProductId, COALESCE(Price, 0) FROM Products How do
I am trying to translate the following query into entity framework: SELECT Subjects.Name FROM
I have the following select statement where I need to sum each task from
Is there a way to select designtime packages on a project bases? Packages are
Visual C++ let's you select the struct members alignemnt in the project's properties page.

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.