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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:46:03+00:00 2026-06-06T18:46:03+00:00

select * from FOO.MBR_DETAILS where BAR= ‘BAZ’ and MBR_No = ‘123’ execution time =

  • 0
select  * from   FOO.MBR_DETAILS where BAR= 'BAZ' and MBR_No = '123'

execution time = 0.25 seconds

CREATE PROCEDURE My.MEMBER_SEARCH
(
        i_BAR varchar(3),
        i_member_surname varchar(50),
        i_member_code varchar(10),
        i_member_given_name varchar(50)
)

    RESULT SETS 1
    LANGUAGE SQL
BEGIN
   DECLARE c1 cursor with return for

          select *
          FROM FOO.MBR_DETAILS m
          WHERE
            BAR= i_BAR
            and  (i_member_code = '' or  m.MBR_No = i_member_code)
            and (i_member_surname = '' or  m.surname = i_member_surname)
            and (i_member_given_name = '' or  m.given_names  LIKE  '%'||i_member_given_name||'%');


    OPEN c1;
END

call My.MEMBER_SEARCH('BAZ','','123','')

execution time = 1.9 seconds

I thought both queries should have a similar time as i_member_surname and i_member_given_name are both empty they would not be evaulated.

  • 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-06T18:46:04+00:00Added an answer on June 6, 2026 at 6:46 pm

    The solution is to enable REOPT ALWAYS for any stored procedure that runs a flexible, parameter-driven search.

    The REOPT ALWAYS option will force the optimizer to analyze the input parameter values and come up with a new access plan every time the procedure is executed, instead of just once when the procedure is compiled. Although REOPT ALWAYS adds a few extra milliseconds of optimizer overhead for each and every execution of the stored procedure, that is most likely faster than continually reusing the one-size-fits-all access plan that the optimizer guessed at while initially compiling the stored procedure.

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

Sidebar

Related Questions

I use parameterized queries, like this: SELECT * FROM foo WHERE bar = :p0
Is there something like SELECT * FROM foo WHERE base64(bar) LIKE '%bararar%' in SQLite?
With SQL Server, I can send SELECT * FROM FOO SELECT * FROM BAR
I want to generate this SQL statement in LINQ: select * from Foo where
$username_decoded = '<i>marco</i>'; $stmt = $this->db->prepare(SELECT * FROM foo WHERE username=:username); $stmt->bindParam(':username',$username_decoded,PDO::PARAM_STR); $stmt->execute(); $all_fetched
Let's say I have something like this: $db=new PDO($dsn); $statement=$db->query('Select * from foo'); while
I've got quite a few SQL statements like such: SELECT foo FROM things WHERE
Let's say I have SELECT name FROM table which gives me something like foo
For example SELECT * FROM foo WHERE (id = 2) OR (id = 14)
I have the following query: SELECT * from foo where timestamp = (select max(timestamp)

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.