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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:22:19+00:00 2026-05-25T19:22:19+00:00

Use of function calls in where clause of stored procedure slows down performance in

  • 0

Use of function calls in where clause of stored procedure slows down performance in sql server 2005?

SELECT * FROM Member M 
WHERE LOWER(dbo.GetLookupDetailTitle(M.RoleId,'MemberRole')) != 'administrator' 
AND LOWER(dbo.GetLookupDetailTitle(M.RoleId,'MemberRole')) != 'moderator' 

In this query GetLookupDetailTitle is a user defined function and LOWER() is built in function i am asking about both.

  • 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-25T19:22:19+00:00Added an answer on May 25, 2026 at 7:22 pm

    Yes.

    Both of these are practices to be avoided where possible.

    Applying almost any function to a column makes the expression unsargable which means an index cannot be used and even if the column is not indexed it makes cardinality estimates incorrect for the rest of the plan.

    Additionally your dbo.GetLookupDetailTitle scalar function looks like it does data access and this should be inlined into the query.

    The query optimiser does not inline logic from scalar UDFs and your query will be performing this lookup for each row in your source data, which will effectively enforce a nested loops join irrespective of its suitability.

    Additionally this will actually happen twice per row because of the 2 function invocations. You should probably rewrite as something like

    SELECT M.* /*But don't use * either, list columns explicitly... */
    FROM Member M 
    WHERE NOT EXISTS(SELECT * 
                     FROM MemberRoles R 
                     WHERE R.MemberId = M.MemberId 
                     AND R.RoleId IN (1,2)
                     )
    

    Don’t be tempted to replace the literal values 1,2 with variables with more descriptive names as this too can mess up cardinality estimates.

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

Sidebar

Related Questions

I've got a query that calls a function in its select clause. The function
I make a lot of use of 'do.call' to generate function calls. E.g: myfun
I need to call some jQuery .load() function from flash. i Use this: import
I need to make a SELECT with a call of a stored procedure in
Is there a way to call a MySQL stored function (not procedure) in Zend
I'm about to use func_get_args for reading additional arguments of a function call. How
I use a function and pipeline its return values. I call the above function
I'm trying to use CallFunction() to call a function inside a flash file, but
I want to use jquery delegate to call a function, and this works fine:
Let's say I need to use Python and C++. I can call Python function

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.