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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:34:08+00:00 2026-05-17T15:34:08+00:00

To perform transformations in my database, I frequently use a chained set of views.

  • 0

To perform transformations in my database, I frequently use a chained set of views. Within the views will be common table expressions. For example I would have the following:

CREATE VIEW TransformationStep1 AS
    WITH Transformation1A AS (
        SELECT Field1, Field2, Field3, Bla(Field1) AS Calc FROM Table1
    ),
    Transformation1B AS (
        SELECT Field1, Field2, Field3, Calc FROM Transformation1A
    )
    SELECT * FROM Transformation1B

CREATE VIEW TransformationStep2 AS
    WITH Transformation2A AS (
        SELECT Field1, Calc FROM TransformationStep1
    ), ....

Somewhere near TransformationStep4 the views will become slower as the query plan becomes more complicated. This is expected and OK.

But when I want to join a part of TransformationStep4 to itself, the query will slow down hugely as the optimizer tries to find its way back all the way to the source tables and look for indexes of some kind. Normally this is OK, but sometimes I just want to store my temporary result and join with that because (being the designing human in the story) I for one know that the result table will be quite small, and it will be much faster to join against a “prefetch” of it.

Is there a way for me to write a query hint, that will influence the query plan in such a way that the subquery will be prefetched and then joined against? Otherwise I’ll have to resort to temp tables in a stored procedure, but I want to avoid it if I can.

Thanks for any suggestions, also when you think my design sucks 🙂

  • 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-17T15:34:08+00:00Added an answer on May 17, 2026 at 3:34 pm

    A view is a macro that expands: there is no caching or pre-fetching pre-calculation.

    Unless you have indexed views where you can use NOEXPAND.. but these will not wok on ordinary views.

    However, you can use inner TOP/ORDER BY to materialise the view too:

    SELECT
       *
    FROM
       (SELECT TOP 2000000000 * FROm TransformationStep2 ORDER BY soemthing) V1
       JOIN
       (SELECT TOP... ) bar on foo.x = bar.x
    

    There is nothing magical about a view: it’s just text and has no memory or persistence…

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

Sidebar

Related Questions

I'm working on a tool that will perform some simple transformations on programs (like
I'd like to perform custom HTML transformations using jQuery for Wordpress posts database (sanify
A seemingly simple issue, I have an off-screen bitmap that I perform some transformations
I would like to perform some encryption on client using the asymmetric key stored
In order to perform less api calls I would like to combine api calls
I am trying to perform a join on two tables. One table contains the
I'm writing an iPhone app which uses GLSL shaders to perform transformations on textures,
I'm attempting to make use of configuration transformations in a continuous integration environment. I
I have a class that can perform many types of transformations to a given
I am trying to write a stored procedure in MySQL which will perform a

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.