简体   繁体   中英

Oracle Stored function Vs Join in queries

I want to retrieve data from two tables.
The two tables are related with a foreign key reference. I've the following two ways to do this. But don't know which one is the better way.

  1. A stored function call from the query
  2. Using a join clause

Which will be the better way? I'm using the technologies: Oracle12c, Java, IBatis. So what is the best way to achieve this?

As join keeps everything at SQL level, it should be a better choice.

Using a function - which is PL/SQL - causes context switching (from SQL to PL/SQL and back to SQL to PL/SQL...) which will take resources.

You won't notice anything if there's a small data set, but - as number of rows involved gets higher, execution time will probably suffer in the second option.

If you'll be testing it, run every option several times because of possible caching.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM