There's a section in "PL/SQL User's Guide and Reference" about PLS_INTEGER. It says that we should use PLS_INTEGER whereever possible.
I copied it over here:
You use the PLS_INTEGER datatype to store signed integers. Its magnitude range is -2**31 .. 2**31. PLS_INTEGER values require less storage than NUMBER values. Also, PLS_INTEGER operations use machine arithmetic, so they are faster than NUMBER and BINARY_INTEGER operations, which use library arithmetic. For efficiency, use PLS_INTEGER for all calculations that fall within its magnitude range.
Although PLS_INTEGER and BINARY_INTEGER have the same magnitude range, they are not fully compatible. When a PLS_INTEGER calculation overflows, an exception is raised. However, when a BINARY_INTEGER calculation overflows, no exception is raised if the result is assigned to a NUMBER variable.
Because of this small semantic difference, you might want to continue using BINARY_INTEGER in old applications for compatibility. In new applications, always use PLS_INTEGER for better performance.
Actually I think this a bit exaggerated. Imho you do not get that much extra performance by using PLS_INTEGER all the time ... it's a lot more important to use the "proper" type instead.
Eg. if you define a collection type as "INDEXED BY BINARY_INTEGER", then use a different type (NUMBER or PLS_INTEGER) for indexing the collection, then you will loose a lot due to all the datatype conversions. But that's just my opinion.
PS: my experience shows that you can spend all your time on PL/SQL optimization ... but you'll get incomparable speed by tweaking a bit here and there on your SQL statements (structure, indexes, etc.).
Recent comments
2 years 34 weeks ago
4 years 3 weeks ago
4 years 3 weeks ago
4 years 5 weeks ago
4 years 6 weeks ago
4 years 13 weeks ago
4 years 13 weeks ago
4 years 13 weeks ago
4 years 13 weeks ago
4 years 14 weeks ago