Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use static methods to improve performance for commonly used methods

I have some methods which allow me to lookup some identifiers, so essentially the run an SQL query and pass back a value.

Currently they are not static. Would it make sense to make them static, from a performance point of view i.e. have less in memory and save the time that is required to instantiate the object? Or are these considerations not really important.

like image 433
Ankur Avatar asked Jan 27 '26 02:01

Ankur


1 Answers

There's no significant difference in practice, one way or another. It's especially true in your case, since SQL queries will take much more time than java method call.

As for memory usage, by making method static you're gonna gain 0 bytes of memory, that's absolutely certain.

like image 54
Nikita Rybak Avatar answered Jan 28 '26 15:01

Nikita Rybak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!