Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9492b5c0
Commit
9492b5c0
authored
Jul 02, 2020
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Edit ordering_table_columns.md, move important info first
parent
98304964
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
doc/development/ordering_table_columns.md
doc/development/ordering_table_columns.md
+5
-5
No files found.
doc/development/ordering_table_columns.md
View file @
9492b5c0
# Ordering Table Columns in PostgreSQL
# Ordering Table Columns in PostgreSQL
For GitLab we require that columns of new tables are ordered to use the
least amount of space. An easy way of doing this is to order them based on the
type size in descending order with variable sizes (
`text`
,
`varchar`
, arrays,
`json`
,
`jsonb`
, and so on) at the end.
Similar to C structures the space of a table is influenced by the order of
Similar to C structures the space of a table is influenced by the order of
columns. This is because the size of columns is aligned depending on the type of
columns. This is because the size of columns is aligned depending on the type of
the following column. Let's consider an example:
the following column. Let's consider an example:
...
@@ -40,11 +45,6 @@ In these examples, the `id` and `user_id` columns are packed together, which
...
@@ -40,11 +45,6 @@ In these examples, the `id` and `user_id` columns are packed together, which
means we only need 8 bytes to store _both_ of them. This in turn means each row
means we only need 8 bytes to store _both_ of them. This in turn means each row
will require 8 bytes less space.
will require 8 bytes less space.
For GitLab we require that columns of new tables are ordered based to use the
least amount of space. An easy way of doing this is to order them based on the
type size in descending order with variable sizes (
`text`
,
`varchar`
, arrays,
`json`
,
`jsonb`
, and so on) at the end.
## Type Sizes
## Type Sizes
While the
[
PostgreSQL documentation
](
https://www.postgresql.org/docs/current/datatype.html
)
contains plenty
While the
[
PostgreSQL documentation
](
https://www.postgresql.org/docs/current/datatype.html
)
contains plenty
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment