BulkMerge: Stop use dynamic temporary table name in PostgreSQL
In PostgreSQL, it is not necessary to use random table names. This hinders the generation of database statistics and makes it difficult for APM tools (such as Datadog, NewRelic, Dynatrace, etc.) to consolidate information.
The proposal is to use the "on commit drop" feature in the table creation command. This will automatically delete the table, even when committing the transaction.
create temp table "(original-table-name)" + "_temp"
on commit drop // <---- new statement
as table (original-table-name) with no data;
At this location in the code
https://github.com/borisdj/EFCore.BulkExtensions/blob/77e17d806bd39b0790a9a6af8d903cb29cc1e347/EFCore.BulkExtensions.PostgreSql/SqlAdapters/PostgreSql/PostgreSqlQueryBuilder.cs#L56-L60
I agree here too, I'm seeing a ton of pg_toast_temp tables because they're not being dropped. We should be including the ON COMMIT DROP statement as part of the creation (If TempDB is enabled)