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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:20:25+00:00 2026-06-03T05:20:25+00:00

What is the fastest in an ORACLE database ? Call a function inside a

  • 0

What is the fastest in an ORACLE database ?

Call a function inside a select statement to retrive a single value for each row

SELECT field1, field2, F_GET_LIBELLE_STATUT( field2 ) FROM table1 WHERE ...

with the simple function :

create or replace
FUNCTION "F_GET_LIBELLE_STATUT" (v_statut NUMBER) RETURN VARCHAR2 IS
tmpVar VARCHAR2(40);
BEGIN
   select libelle into tmpVar from t_statut_ope where id_statut = v_statut;
   RETURN tmpVar;
   EXCEPTION
     WHEN NO_DATA_FOUND THEN
       RETURN '';
     WHEN OTHERS THEN
       -- Consider logging the error and then re-raise
       RAISE;
END f_get_libelle_statut;

Or doing a join in the select statement ?

Select a.field1, a.field2, b.libelle
FROM table1 a LEFT JOIN t_statut_ope b ON b.id_statut = a.field2
WHERE ...

And is it the same answer if I call a lot of functions (ten or more) in the select and in the clause condition ?

Thanks for your answer.

  • 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-03T05:20:26+00:00Added an answer on June 3, 2026 at 5:20 am

    Anything which can be done in SQL should be done in SQL (*).

    A join will always be faster than calling that function because set-based operations are always faster than row by agonizing row. Then you have the overhead of moving between SQL and PL/SQL. Plus the overhead of handling those NO_DATA_FOUND exceptions, which aren’t truly exceptions because gaps are expected and tolerated. Finally, the optimizer will pick a better plan for the pure SQL option because you have given it all the information it needs.


    (*) I answered this question way back when and I answered it focused on the example given, and I stand by that answer. If we can get the data we need using SQL against tables (via joins, views, inline views, subqueries) then we should do that. But I want to drill down into the underlying question: why does Oracle support the use of functions in queries? Because sometimes we need to do things we can’t do in SQL.

    Here are use cases for calling functions that execute SQL (I am thinking primarily of functions invoked through table() calls ) instead of using a join (or other SQL constructs such as inline view, WITH clause) :

    1. Query is dynamic. Dynamic SQL requires PL/SQL so a function is yer only man here.
    2. Row generation. Using PL/SQL to split the input into multiple strings (such as CSV tokenizing) or perhaps to spawn data, not from a table. Occasionally still valid but regex support and the nifty CONNECT BY LEVEL <= N trick have binned the more common usages.
    3. The data is encapsulated behind a PL/SQL API so a function is all we can call.
    4. For some bizarre reason we can only get the performance we need by using PL/SQL to implement a filter or a look-up. Apparently. To be honest I can’t ever remember a case where I had to do this and it worked (although I’ve had a few cases where turning a pipelined function into a subquery or inline view improved performance). Maybe I’ve led a sheltered life. Certainly, I would welcome benchmarked citations for counter-examples.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What's the fastest way to reset every value of a std::vector<int> to 0 and
I'm in the process of cleaning up an Oracle database application. In this application,
I've notice that in Oracle, the query SELECT COUNT(*) FROM sometable; is very slow
Which is generally fastest when reading/comparing row info from a DataTable? 'assume dt as
By fastest I mean what is the most performant means of converting each item
I'm looking for the fastest way to determine if a long value is a
Fastest way to uniqify a list in Python without preserving order? I saw many
What's the fastest way using either DOS scripting or PowerShell to run this simple
What's the fastest way to enumerate through an integer and return the exponent of
What is the fastest way to compare a string with an array of strings

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.