... function returning hardcoded value 42. Select row selects a single row from table having 10k rows. plpgsql being faster than sql is surprising for the second case.