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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:19:45+00:00 2026-06-13T09:19:45+00:00

Take a look at this fiddle: http://sqlfiddle.com/#!6/18324/2 Expand the very first execution plan, for

  • 0

Take a look at this fiddle: http://sqlfiddle.com/#!6/18324/2

Expand the very first execution plan, for the queries against view B.
Notice that the first query executes using index seek, while the second one – using index scan. In my real setup, with thousands of rows, this produces a performance hit that is quite considerable.

WTF???

The queries are equivalent, aren’t they? Why does a literal produce seek and a variable – scan?
But more importantly: how can I work around this?

This post comes closest to the problem, and the solution that works from there is using option(recompile) (thank you, Martin Smith). However, that does not work for me, because my queries are being generated by my ORM library (which is Entity Framework) and I cannot amend them manually.
Rather what I’m looking for is a way to reformulate the B view so that the problem would not occur.

While fiddling with this problem, I have noticed that it is always the “Segment” block in the execution plan that loses the predicate. To verify this, I reformulated the query in terms of a subquery with min function (see view D). And voila! – both queries against the D view produce identical plans.

The bad news, however, is that I cannot use this min-powered trick, because in my real setup, the column Y is actually several columns, so that I can order by them, but I cannot take a min() of them.
So the second question would be: can anyone come up with a trick that is similar to min-powered subquery, but works for several columns?

NOTE 1: this is definitely not related to the tipping point, because there are just 2 records in the table.
NOTE 2: it also doesn’t have to do with the presence of a view. See an example with view C: the server is happily using seek in that 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-13T09:19:46+00:00Added an answer on June 13, 2026 at 9:19 am

    Here is my own answer.

    Ultimately, I used the min-powered trick, and I got around the fact that Y is actually several columns by converting those columns into constant-length string representations (carefully tuned for sorting) and joining those strings together into one string. After that is done, I am able to use that joined string as the argument for min().

    I still would like to know the proper way of doing this. If anyone happens to know it, I’d appreciate.

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

Sidebar

Related Questions

Please take a look at this fiddle: http://jsfiddle.net/KA85s/3/ JQ-UI sets first option as default.
Please take a look at this fiddle http://jsfiddle.net/Qstuw/7/ First answer is selected by default,
Hi please take a look at this fiddle http://jsfiddle.net/bloodygeese/pwjNQ/1/ I am trying to figure
take look at this: http://www.templatemonster.com/demo/35403.html In this template you can click on the image
Take a look at this example here: http://denise.brixwork.com/showlisting/1/8297-Valley-Drive-Alpine-Meadows-Whistler-denise-brown-real-estate And the red tables under Specifications
Take a look at this fiddle: http://jsfiddle.net/FK3cd/3/ What I want is for the <li>
If you take a look at this fiddle in Chrome: http://jsfiddle.net/up4Fa/ You will see
Please take a look at this fiddle jsfiddle.net/Qstuw/2/ As you see from picture first
Take a look at this fiddle : http://jsfiddle.net/3JRU6/ $(document).ready(function(){ var url='http://api.worldbank.org/topic/4?per_page=10&format=json&callback=?'; var query; $('button').click(function(){
Possible Duplicate: .prop() vs .attr() Please take a look at this fiddle: http://jsfiddle.net/DGzvP/ $(#test).prop({

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.