one word, horizontal structure. you are trying to sort 1500 colums, instead of creating 1500 rows per entry...
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных