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 7601977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:17:45+00:00 2026-05-30T23:17:45+00:00

It will take up to 4.5 sec on a fast server to make this

  • 0

It will take up to 4.5 sec on a fast server to make this query to be finished and output the result on a table with 400K rows

the output
Month Week Views
02 27 581

SELECT 
  DATE_FORMAT(`DataDateTime`, '%m') AS `Month`, 
  DATE_FORMAT(`DataDateTime`, '%d') AS `Day`, 
  COUNT(DISTINCT(`DataUserID`)) AS `Views`
FROM `la_data` 
WHERE
  `DataLayerName` = 'layar' 
  AND `DataDateTime` > '' 
GROUP BY `Day`, `Month` 
HAVING `Day` = 27 AND `Month` = 02 
ORDER BY `Views` DESC
  • 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-30T23:17:47+00:00Added an answer on May 30, 2026 at 11:17 pm

    The HAVING clause is meant to be used to limit the results once the ORDER BY and
    GROUP BY clauses have been processed. Since they are processed after the main query has taken place they can’t be optimized which is why the query is taking so long. As the Day and Month functions are not affected by either of these clauses, they should be in the WHERE clause instead. Try putting them in there instead (note you must use the full expressions in the WHERE):

    ...
    WHERE
      `DataLayerName` = 'layar' 
      AND `DataDateTime` > ''
      AND DATE_FORMAT(`DataDateTime`, '%d') = 27
      AND DATE_FORMAT(`DataDateTime`, '%m') = 02
    GROUP BY `Day`, `Month` 
    ORDER BY `Views` DESC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This function will take a particular node of linked list and make it Last
This one will take some explaining. What I've done is create a specific custom
Is there a tool that will take you java beans (pojos) and automatically make
It will take a moment for me to explain this, so please stay with
I'm sure this question will take one of you 3 seconds to answer but
which will take more execution time insert operation or select operation if both are
My program will take arbitrary strings from the internet and use them for file
I am looking for a tool which will take an XML instance document and
Estimating how long any given task will take seems to be one of the
Does anyone have an XSLT that will take the app.config and render it into

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.