PsqlTetris.Optimizer (PsqlTetris v0.1.1)

View Source

Pure ordering logic. Given a list of column descriptors, returns them in the order PostgreSQL would prefer for minimal row padding.

A column descriptor is a map (or struct-shaped map) with at least:

  • :type : the Ecto migration type (atom or tuple)
  • :opts : keyword list passed to add/3 (may be [])

Any other keys are preserved untouched.

The sort is stable, so columns of the same alignment rank keep their author-defined order. Within a rank, null: false columns come first, which is a tiny CPU win during tuple deforming.

Summary

Functions

optimize(columns)

@spec optimize([map()]) :: [map()]