Some of my newer tables are now using UUID type fields as PKey and older tables are still using
bigserial. I have several tables (let's call them entities) I would like to query returning the primary key in the result (using a UNION). What is the most efficient way to return the entity_id's? I am assuming a simple CAST would do the trick, but this is to handle a sitewide search which requires it to be as quick as possible.
select entityA.a_id::TEXT as entity_id from entityA union select entityB.b_uuid::TEXT as entity_id from entityB union select entityC.c_id::TEXT as entity_id from entityC union select entityD.d_id::TEXT as entity_id from entityD union select EntityE.e_id::Text as entity_id from EntityE