8

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.

Erwin Brandstetter
  • 185,527
  • 28
  • 463
  • 633
jmn
  • 83
  • 1
  • 3

1 Answers1

11

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.
Erwin Brandstetter
  • 185,527
  • 28
  • 463
  • 633