patternsqlModerate
Does the length of a table name affect performance?
Viewed 0 times
thelengthaffectnameperformancedoestable
Problem
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.
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.
Solution
Table names have to be stored just like any other data (in the system catalog
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:
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.
Context
StackExchange Database Administrators Q#61391, answer score: 10
Revisions (0)
No revisions yet.