core: Database functions not fully optimized

Set all functions that only SELECT data as STABLE
Set all functions that do not change the DB or perform any lookups
(select) to IMMUTABLE

Change-Id: I29a355286f5e6c23afe64c63efefe311c65be581
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=905383
Signed-off-by: Eli Mesika <emesika@redhat.com>