Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

PostgreSQL table names are limited to 63 chars.

Is there a performance gain to be had if I limit my table names to something like 5 chars or can I use the full 63 chars without consequence?

I understand it will be longer to type long names when creating queries, but that's what aliases are for.

share|improve this question
1  
No, I doubt there is difference in performance. No reason to limit to 5 characters and seriously, will you ever need 63 characters for a name? –  ypercube Mar 20 at 20:44
    
@hypercube : well right now in my conceptual model I have a 20+ char name, something like 'customer_pays_for_user'. I was wondering if I should start to shorten the long names or just go with it. –  jmn Mar 21 at 19:24
add comment

1 Answer 1

up vote 4 down vote accepted

Table names have to be stored just like any other data (in the system catalog pg_class to be precise), and there are multiple objects that are typically named matching the table name (constraints, indexes, sequences, ...) so there is a marginal cost for longer strings. But you will not be able to notice any difference in performance. Internal references are implemented with oid numbers (object identifier types), so independent of the string used as name.

The more important consideration is that your code becomes longer and harder to read and type. Typos more likely. Aliases are nice, but you still have to spell out the name in many places. So the rule of thumb should be:

  • As short as possible.
  • As long as necessary to be clear.
share|improve this answer
    
'But you will not be able to notice any difference in performance.' does this hold true if I have several thousand users accessing the database ? –  jmn Mar 21 at 19:26
    
@jmn: Yes. The performance penalty is just too marginal. –  Erwin Brandstetter Mar 21 at 19:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.