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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:18:10+00:00 2026-05-13T17:18:10+00:00

I’ve got an application that generates data for reports that look like: age <

  • 0

I’ve got an application that generates data for reports that look like:

                    age < 30   | age >=30  |   asian   | hispanic
-----------------------------------------------------------------
clients in prog A              |          |           |
-----------------------------------------------------------------
clients in prog B              |          |           |
-----------------------------------------------------------------
number clients                 |          |           |
-----------------------------------------------------------------
number children                |          |           |

The queries are sometimes very very long, and I’d like to optimize them.

I don’t have permissions on the server to run the query analyzer (and I read that it’s often better not to use it’s suggestions). The longest sprocs take ~35 seconds to execute.

Reading around, the things to avoid for high query optimization are :

  • Select *
  • exists
  • distinct
  • cursors
  • having

I have a few questions about the task at hand:

  • how much of a difference am I looking at by changing Select * into Select colA, colB … ? Is it really worth the trouble?
  • how can I optimize if exists( … )? Is if( Select Count(query ) > 0 ) a good optimization?
  • If I am really going to return all of the columns in a table, is it okay to use Select * ?

I don’t want to post these queries because they are so long and terrible, but what other suggestions might you be able to offer? I’m trying to use re-usable functions and temporary tables wherever possible to ease the strain both on my brain and on the server.

  • 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-13T17:18:11+00:00Added an answer on May 13, 2026 at 5:18 pm

    1) how much of a difference am I looking at by changing Select * into Select colA, colB … ? Is it really worth the trouble?

    That can make quite a big difference – it’s always good practice generally to specify the fields you want and ONLY those fields. i.e. if you do a SELECT * to return 50 fields when you only need 2 of them, and those 2 fields are included in a suitable index then all the data can be provided from the index without having to look up the rest of the data from the data pages. So this is much better.

    2) how can I optimize if exists( … )? Is if( Select Count(query ) > 0 ) a good optimization?

    No…SELECT COUNT() is worse. EXISTS is the most performant way to do this kind of thing as it is optimised to stop checking as soon as it finds the first matching record. Whereas COUNT() will keep going til it’s found them all which is unnecessary. I wouldn’t be classing “EXISTS” in the bad camp with cursors at all tbh.

    3) If I am really going to return all of the columns in a table, is it okay to use Select *?

    Well, if you truly want them all then it doesn’t matter as much. That assumes if you want to add more columns in future then you also want those to also be returned which could break existing code if it suddenly changes.

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

Sidebar

Ask A Question

Stats

  • Questions 414k
  • Answers 415k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There is nothing wrong with that css. However, your link… May 15, 2026 at 8:51 am
  • Editorial Team
    Editorial Team added an answer Most MVC frameworks have the ability to temporarily store a… May 15, 2026 at 8:51 am
  • Editorial Team
    Editorial Team added an answer This is a perfect situation for autorelease. return [var autorelease];… May 15, 2026 at 8:51 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.