You probably have some columns that are common to almost all products: Price, SKU, Manufacturer, etc. Those may as well be columns. The rest can be put into a JSON string. More discussion: http://mysql.rjweb.org/doc.php/eav
Its possible to use type JSON
this negates the need for a table of custom fields, however if you need to do join/look ups on this data, it will be difficult.
Tell PostgreSQL not to use the index by using
ORDER BY contacts__aggregated_1.value + 0 ASC
The problem is that PostgreSQL thinks it will be fastest if it scans contacts__aggregated in the ORDER BY order using the index, uses a nested loop to add rows from the other tables and filters out values that don't satisfy the conditions.
This is often a good ...