postgres ERROR: target lists can have at most 1664 entries SQL state: 54000 In my query, I want to have more than 1700 columns but I got this error:

"ERROR: target lists can have at most 1664 entries SQL state: 54000"


I'm using postgres10 on Windows. 

Has anyone come across this before? Any ideas for a solution?
Such column count is really huge. Without the schema/query details I cannot say, what's the reason, but I might guess there are many data columns not really required to be serialized there. Instead doing some concat magic I would suggest to merge such columns into JSON/JSONB objects which would be then easily accessible by the application. This is the classic NoSQL approach in SQL RDBMSes.