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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:46:22+00:00 2026-06-10T04:46:22+00:00

If we have a SQL view VIEW_MYTABLE with, say, 50 columns. Option 1 :

  • 0

If we have a SQL view VIEW_MYTABLE with, say, 50 columns.

Option 1:

with CTE_MYQUERY1 as (
  select [VIEW_MYTABLE].*
  from [VIEW_MYTABLE]
  /*some complex where clause*/
)

Option 2:

with CTE_MYQUERY2 as (
  select [COLUMN_1], [COLUMN_2], [COLUMN_3], ...., [COLUMN_10]
  from [VIEW_MYTABLE]
  /*some complex where clause*/
)

As per my understanding, select with columns defined is always faster than the select * statement. Note that in this second query I am selecting only 10 of the 50 columns in the view.

I am getting both result as same? Can anyone also let me know how CTE works internally, does it first generate result set and then fed it to the subsequent query (SELECT query in my case)?

  • 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-10T04:46:23+00:00Added an answer on June 10, 2026 at 4:46 am

    I would expect absolutely no discernible difference in runtimes between these two queries.

    However, I would still advocate against SELECT *, and not for performance reasons. There is a long-established myth that SELECT * is less efficient because the engine has to go look up the column names in the metadata, but the truth is that there is still a lookup to validate the column names you’ve written, and the additional cost of retrieving the names is going to be unnoticeable by humans regardless of the result set size.

    The reasons I advocate against SELECT * is that:

    • it is unlikely you need all of the columns from the table (or all rows, but that’s a different story). If you are pulling back more columns than you need, you are doing unnecessary I/O and perhaps forcing SQL Server to perform a table/clustered index scan when it could have performed a scan on a much skinnier index.

    • even if you do need all of the columns, using SELECT * can cause hard-to-detect problems in your code later. What if someone inserts a column into the middle of the table? Drops a column? Adds a column? Renames a column? Some of these will be caught immediately but I’ve demonstrated cases where this can cause all kinds of hard-to-debug problems.

      • Bad habits to kick : using SELECT * / omitting the column list

    As for how CTEs work in general, that’s a pretty broad question here. I’d start with these articles:

    http://www.simple-talk.com/sql/t-sql-programming/sql-server-cte-basics/

    https://learn.microsoft.com/en-us/previous-versions/sql/sql-server-2008/ms190766(v=sql.100)

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

Sidebar

Related Questions

I am getting some strange behaviour from SQL Server. I have an underlying view
I have an SSIS package that queries data from a view using an SQL
I have a view in SQL server that translates from one schema version to
I have a SQL Server View: SELECT SOPOrderReturn.DocumentNo, StockItem.Code, SLCustomerAccount.CustomerAccountNumber, SOPOrderReturn.CustomerID, SOPDocDelAddress.PostalName, SOPDocDelAddress.AddressLine1, SOPDocDelAddress.AddressLine2,
I have an SQL view that is using this query: SELECT dbo.FBAShipmentItems.ShipmentID, dbo.FBAShipmentItems.FNSKU, dbo.FBAShipmentItems.ASIN,
I have got a sql table view where one of the columns is calculated:
In a web application, I have to select ~1 million rows from a SQL
I have below SQL query: SELECT * FROM ( SELECT S.aCol, S.bCol, S.cCol, ROW_NUMBER()
I have a MS SQL view that I want to make available as a
I currently have this statement in my SQL View (SQL Server 2008 R2) which

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.