I would like to perform spatial identity operation (ArcGIS example here) using PostGIS. I have two polygon tables, one of which is the input layer and the other table is the overlay layer. The output should be the original input layer but broken up to pieces where the overlay layer intersects it. This could get complex as multiple overlay polygons can intersect the input polygons. The output table need to have all the original fields of the input table plus a column from the overlay table. This extra column will have the data from the overlay table where they intersect and a fixed value like -1 or NA in non-overlapping areas.
How can this be done in PostGIS?
I am looking for an efficient solution as my input table has about 400k and my overlay table has about 20 million records.