Performance Impact Splitting View into View of Views










0















I have a view that pulls from approximately 30 different tables. There is one master table, and 29 tables that left join to the master.



-- master view
select
m.mkey, m.x, m.y, a.i, func(b.j) bjfunc, c.k ...
from
master m left join
atable a on
m.akey = a.akey left join
btable b on
m.bkey = b.bkey left join
ctable c on
m.ckey = c.ckey
...


We have an application that requires the view as is, using all data returned from it, so I need to maintain it as is. As we continue to develop, we're finding ourselves selecting sub-sets of the view as well for other applications. In this case we simply can't use the view as it's far too heavy for what's needed, and we end up creating new views, that duplicate a portion of the main view.



-- sub-view abview
select
m.mkey, m.y, a.i, func(b.j) bjfunc
from
master m left join
atable a on
m.akey = a.akey left join
btable b on
m.bkey = b.bkey


I'm thinking I can substitute this sub-view back into the master view as follows:



-- master view
select
m.mkey, m.x, ab.y, ab.i, ab.bjfunc, c.k ...
from
master m left join
abview ab on
m.mkey = ab.mkey left join
ctable c on
m.ckey = c.ckey
...


This would help to keep the two views synchronized, and make the master view a little more aesthetically pleasing by cutting the joins/aliases in half.



Finally:
My question is how much would this affect the performance of the master view? I'm not sure how well the optimizer would handle bringing those sub-views together. Linking each sub-view on a master table lookup vs. the original master view linking all tables on the master table at once.



Am I better off just maintaining separate views?




Edit: Using SQL Server 2016



I've been doing some benchmarking.



I can see the number of logical reads against the master table increasing each time I break out a new sub-view.



The query duration appears to be only slightly affected. I think the question is now of maintainability vs performance, and where to balance the two.










share|improve this question
























  • Which dbms are you using?

    – jarlh
    Nov 15 '18 at 16:47






  • 1





    From a developer maintenance stand point, I feel it is better to compose your main VIEW from a selection of sub-views (so to speak). However, depending on your RDBMS system (I use primarily MYSQL) using VIEW's, especially with lots of JOIN's can really kill performance. I had a similar design where a workorder table JOIN'ed to dozens of tables and the main search halted to crawl - because of the JOIN's and the use of a "master" VIEW. I ended up reworking the search code to manually build the required SQL.

    – Alex.Barylski
    Nov 15 '18 at 16:52











  • @jarlh SQL Server 2016

    – Jamie
    Nov 15 '18 at 17:27















0















I have a view that pulls from approximately 30 different tables. There is one master table, and 29 tables that left join to the master.



-- master view
select
m.mkey, m.x, m.y, a.i, func(b.j) bjfunc, c.k ...
from
master m left join
atable a on
m.akey = a.akey left join
btable b on
m.bkey = b.bkey left join
ctable c on
m.ckey = c.ckey
...


We have an application that requires the view as is, using all data returned from it, so I need to maintain it as is. As we continue to develop, we're finding ourselves selecting sub-sets of the view as well for other applications. In this case we simply can't use the view as it's far too heavy for what's needed, and we end up creating new views, that duplicate a portion of the main view.



-- sub-view abview
select
m.mkey, m.y, a.i, func(b.j) bjfunc
from
master m left join
atable a on
m.akey = a.akey left join
btable b on
m.bkey = b.bkey


I'm thinking I can substitute this sub-view back into the master view as follows:



-- master view
select
m.mkey, m.x, ab.y, ab.i, ab.bjfunc, c.k ...
from
master m left join
abview ab on
m.mkey = ab.mkey left join
ctable c on
m.ckey = c.ckey
...


This would help to keep the two views synchronized, and make the master view a little more aesthetically pleasing by cutting the joins/aliases in half.



Finally:
My question is how much would this affect the performance of the master view? I'm not sure how well the optimizer would handle bringing those sub-views together. Linking each sub-view on a master table lookup vs. the original master view linking all tables on the master table at once.



Am I better off just maintaining separate views?




Edit: Using SQL Server 2016



I've been doing some benchmarking.



I can see the number of logical reads against the master table increasing each time I break out a new sub-view.



The query duration appears to be only slightly affected. I think the question is now of maintainability vs performance, and where to balance the two.










share|improve this question
























  • Which dbms are you using?

    – jarlh
    Nov 15 '18 at 16:47






  • 1





    From a developer maintenance stand point, I feel it is better to compose your main VIEW from a selection of sub-views (so to speak). However, depending on your RDBMS system (I use primarily MYSQL) using VIEW's, especially with lots of JOIN's can really kill performance. I had a similar design where a workorder table JOIN'ed to dozens of tables and the main search halted to crawl - because of the JOIN's and the use of a "master" VIEW. I ended up reworking the search code to manually build the required SQL.

    – Alex.Barylski
    Nov 15 '18 at 16:52











  • @jarlh SQL Server 2016

    – Jamie
    Nov 15 '18 at 17:27













0












0








0








I have a view that pulls from approximately 30 different tables. There is one master table, and 29 tables that left join to the master.



-- master view
select
m.mkey, m.x, m.y, a.i, func(b.j) bjfunc, c.k ...
from
master m left join
atable a on
m.akey = a.akey left join
btable b on
m.bkey = b.bkey left join
ctable c on
m.ckey = c.ckey
...


We have an application that requires the view as is, using all data returned from it, so I need to maintain it as is. As we continue to develop, we're finding ourselves selecting sub-sets of the view as well for other applications. In this case we simply can't use the view as it's far too heavy for what's needed, and we end up creating new views, that duplicate a portion of the main view.



-- sub-view abview
select
m.mkey, m.y, a.i, func(b.j) bjfunc
from
master m left join
atable a on
m.akey = a.akey left join
btable b on
m.bkey = b.bkey


I'm thinking I can substitute this sub-view back into the master view as follows:



-- master view
select
m.mkey, m.x, ab.y, ab.i, ab.bjfunc, c.k ...
from
master m left join
abview ab on
m.mkey = ab.mkey left join
ctable c on
m.ckey = c.ckey
...


This would help to keep the two views synchronized, and make the master view a little more aesthetically pleasing by cutting the joins/aliases in half.



Finally:
My question is how much would this affect the performance of the master view? I'm not sure how well the optimizer would handle bringing those sub-views together. Linking each sub-view on a master table lookup vs. the original master view linking all tables on the master table at once.



Am I better off just maintaining separate views?




Edit: Using SQL Server 2016



I've been doing some benchmarking.



I can see the number of logical reads against the master table increasing each time I break out a new sub-view.



The query duration appears to be only slightly affected. I think the question is now of maintainability vs performance, and where to balance the two.










share|improve this question
















I have a view that pulls from approximately 30 different tables. There is one master table, and 29 tables that left join to the master.



-- master view
select
m.mkey, m.x, m.y, a.i, func(b.j) bjfunc, c.k ...
from
master m left join
atable a on
m.akey = a.akey left join
btable b on
m.bkey = b.bkey left join
ctable c on
m.ckey = c.ckey
...


We have an application that requires the view as is, using all data returned from it, so I need to maintain it as is. As we continue to develop, we're finding ourselves selecting sub-sets of the view as well for other applications. In this case we simply can't use the view as it's far too heavy for what's needed, and we end up creating new views, that duplicate a portion of the main view.



-- sub-view abview
select
m.mkey, m.y, a.i, func(b.j) bjfunc
from
master m left join
atable a on
m.akey = a.akey left join
btable b on
m.bkey = b.bkey


I'm thinking I can substitute this sub-view back into the master view as follows:



-- master view
select
m.mkey, m.x, ab.y, ab.i, ab.bjfunc, c.k ...
from
master m left join
abview ab on
m.mkey = ab.mkey left join
ctable c on
m.ckey = c.ckey
...


This would help to keep the two views synchronized, and make the master view a little more aesthetically pleasing by cutting the joins/aliases in half.



Finally:
My question is how much would this affect the performance of the master view? I'm not sure how well the optimizer would handle bringing those sub-views together. Linking each sub-view on a master table lookup vs. the original master view linking all tables on the master table at once.



Am I better off just maintaining separate views?




Edit: Using SQL Server 2016



I've been doing some benchmarking.



I can see the number of logical reads against the master table increasing each time I break out a new sub-view.



The query duration appears to be only slightly affected. I think the question is now of maintainability vs performance, and where to balance the two.







sql sql-server sql-view






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 22:54







Jamie

















asked Nov 15 '18 at 16:40









JamieJamie

758




758












  • Which dbms are you using?

    – jarlh
    Nov 15 '18 at 16:47






  • 1





    From a developer maintenance stand point, I feel it is better to compose your main VIEW from a selection of sub-views (so to speak). However, depending on your RDBMS system (I use primarily MYSQL) using VIEW's, especially with lots of JOIN's can really kill performance. I had a similar design where a workorder table JOIN'ed to dozens of tables and the main search halted to crawl - because of the JOIN's and the use of a "master" VIEW. I ended up reworking the search code to manually build the required SQL.

    – Alex.Barylski
    Nov 15 '18 at 16:52











  • @jarlh SQL Server 2016

    – Jamie
    Nov 15 '18 at 17:27

















  • Which dbms are you using?

    – jarlh
    Nov 15 '18 at 16:47






  • 1





    From a developer maintenance stand point, I feel it is better to compose your main VIEW from a selection of sub-views (so to speak). However, depending on your RDBMS system (I use primarily MYSQL) using VIEW's, especially with lots of JOIN's can really kill performance. I had a similar design where a workorder table JOIN'ed to dozens of tables and the main search halted to crawl - because of the JOIN's and the use of a "master" VIEW. I ended up reworking the search code to manually build the required SQL.

    – Alex.Barylski
    Nov 15 '18 at 16:52











  • @jarlh SQL Server 2016

    – Jamie
    Nov 15 '18 at 17:27
















Which dbms are you using?

– jarlh
Nov 15 '18 at 16:47





Which dbms are you using?

– jarlh
Nov 15 '18 at 16:47




1




1





From a developer maintenance stand point, I feel it is better to compose your main VIEW from a selection of sub-views (so to speak). However, depending on your RDBMS system (I use primarily MYSQL) using VIEW's, especially with lots of JOIN's can really kill performance. I had a similar design where a workorder table JOIN'ed to dozens of tables and the main search halted to crawl - because of the JOIN's and the use of a "master" VIEW. I ended up reworking the search code to manually build the required SQL.

– Alex.Barylski
Nov 15 '18 at 16:52





From a developer maintenance stand point, I feel it is better to compose your main VIEW from a selection of sub-views (so to speak). However, depending on your RDBMS system (I use primarily MYSQL) using VIEW's, especially with lots of JOIN's can really kill performance. I had a similar design where a workorder table JOIN'ed to dozens of tables and the main search halted to crawl - because of the JOIN's and the use of a "master" VIEW. I ended up reworking the search code to manually build the required SQL.

– Alex.Barylski
Nov 15 '18 at 16:52













@jarlh SQL Server 2016

– Jamie
Nov 15 '18 at 17:27





@jarlh SQL Server 2016

– Jamie
Nov 15 '18 at 17:27












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53324086%2fperformance-impact-splitting-view-into-view-of-views%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53324086%2fperformance-impact-splitting-view-into-view-of-views%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

ReactJS Fetched API data displays live - need Data displayed static

政党