According to About PostgreSQL it is "250 - 1600 depending on the type of columns." See "Limits." Column types affect it because PostgreSQL rows can have no more than 8kb (one page), they cannot span pages. Larger column values ββare OK because TOAST handles this, but there is a limit to the number of columns that you can fit in, depending on how widely non-displayable data types are used.
(Strictly speaking, this refers to columns that can be stored in rows on disk, and queries can have a wider range of columns than this. I do not recommend relying on it.)
If you are even considering approaching the borders of the columns, you are likely to have problems.
Matching tables with relational databases looks like the easiest thing in the world - matching columns to columns, rows, and rows. Right? In fact, spreadsheets are huge free-form monsters that don't provide any structure and can be really worthless. Relational databases are designed to handle more rows, but at a cost; in the case of PostgreSQL, part of this cost is a limitation on how wide it is for those rows. When faced with spreadsheets created by Joe User, this can be a real problem.
One βsolutionβ is to decompose them into EAV , but it is unbearably slow and ugly to work. The best solutions use arrays where possible, composite types, hstore , json, xml, etc.
In the end, however, the best answer is to parse the table using a spreadsheet.
Craig Ringer Sep 27 2018-12-12T00: 00Z
source share