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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:40:20+00:00 2026-06-05T06:40:20+00:00

In my basic understanding of an index, the index is used on a column

  • 0

In my basic understanding of an index, the index is used on a column in a WHERE clause. Since the HAVING clause is similar to a WHERE clause applied after a GROUP BY statement, does an index have the same effect on that? For example:

SELECT * FROM table WHERE full_name = 'Bob Jones'
--> index on full_name would be beneficial here

and

SELECT * FROM table WHERE first_name = 'Bob' 
GROUP BY
    height HAVING height > 72

In this second query, would an index on both first_name and height improve the performance? Which index would be more important, or are they roughly the equivalent? Also, do indexes improve GROUP BY performance as well (regardless of a HAVING)?

  • 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-06-05T06:40:22+00:00Added an answer on June 5, 2026 at 6:40 am

    A HAVING clause is essentially the last thing done to filter a query’s results before they’re sent off to the client. It’s only useful if you need to filter on the results of an aggregate function, whose value can NOT be available during the row-level filtering that WHERE clauses do.

    Essentially, a HAVING clause can be seen as applying another query, turning your main query into a subquery.

    e.g.

    SELECT ...
    FROM sometable
    HAVING somefield = X
    

    is really no different that

    SELECT *
    FROM (
       SELECT ...
       FROM sometable
    )
    WHERE somefield = X
    

    If the field you’re filtering with the HAVING is NOT a derived field (aggregate value, calculated field, etc…) then you’re almost certainly better off doing the filtering at the WHERE level, which keeps unecessary rows from being loaded off disk in the first place.

    Since having is applied last, rows will be loaded from disk, then possibly discarded if they don’t match the HAVING criteria.

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

Sidebar

Related Questions

In my basic understanding of indexes and running of the explain statement, it seems
I think I have a basic understanding of this, but am hoping that someone
I think I have a basic understanding of REST, but something I'm stuck on
I'm not a monad-jedi yet, but I have a basic understanding of them. Now
I have some basic questions around understanding fundamentals of Performance testing. I know that
I have a very basic understanding of shell scripting, but what I need to
Trying to get some basic understanding of console functionalities. I am having issues so
I have a basic understanding of instanceof in JavaScript, testing if the left hand
I'm starting to dive into TFS 2012 and I have a basic understanding of
I'm fairly new to iOS programming, but have a basic understanding of it. I

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.