How to optimize a fetch into a crosstab
SELECT *
FROM   crosstab(
       'SELECT ad_id, d.name, d.valueofname
        FROM   users
        LEFT   JOIN users_details d USING (ad_id)
        ORDER  BY 1'

    , $$VALUES ('name'), ('age'), ('birthday'), ('job')$$
   ) AS ct (ad_id int, name text, age text, birthday text, job text);


The LEFT JOIN to keep users without any data in the result. If that never occurs or is not desirable, remove the table users from the query completely - it has no other use here.

Detailed explanation for crosstab():


PostgreSQL Crosstab Query


The major advantage over alternative solutions is top performance, which seems to be your prime objective.