Postgresql Create Table From Query Sql Running Slow