'Postgres: How to forbird the use of SELECT * (star)

The use of star in a query can come for sure handy, however it is a pain if many devs in a large organization are using it and rely on it.

Hence I'm wondering if we can forbid the use of * to all user (or certain users)



Solution 1:[1]

you cant, but there is the way =)

of course you can always teach and write letters to users by explaining why the cant do that, but thats not work for us ...

what we come up with this - to check by procedure the users with huge performance issues with their queries and than you can:

  1. just kill by pid , but thats the evil things to do =). OR you can kill only the users that uses * in their queries. But we kill only with a huge date or in strange status.
  2. you can send a letter to user (if of course users registered by email or LDAP and by LDAP than its possible to get the email)

to check the statistics

select * from pg_stat_activity;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 alexandr.besan