Use a an actual subquery to select from instead of a subquery expression:
UPDATE user_stats s
SET ave_price = x.ave_price
FROM (
SELECT user_id
,avg(l.price) AS ave_price
FROM lengths l
JOIN user_sessions us ON us.session_id = l.session_id
WHERE l.product_type = 'car'
GROUP BY us.user_id
HAVING avg(l.price) IS NOT NULL
) x
WHERE x.user_id = s.user_id;
This will be faster, too.
If you have a relevant proportion of user_id that exists in the table user_sessions, but not in user_stats, then the following query might be faster (while both yield the same result in every case):
UPDATE user_stats s
SET ave_price = x.ave_price
FROM (
SELECT user_id
,avg(l.price) AS ave_price
FROM lengths l
JOIN user_stats usr USING (user_id)
JOIN user_sessions us ON us.session_id = l.session_id
WHERE l.product_type = 'car'
GROUP BY us.user_id
HAVING avg(l.price) IS NOT NULL
) x
WHERE x.user_id = s.user_id;
The point of the second version is to exclude irrelevant rows early.
The same query written with a CTE (somewhat more elegant and readable):
WITH x AS (
SELECT user_id
,avg(l.price) AS ave_price
FROM lengths l
JOIN user_stats usr USING (user_id)
JOIN user_sessions us ON us.session_id = l.session_id
WHERE l.product_type = 'car'
GROUP BY us.user_id
HAVING avg(l.price) IS NOT NULL
)
UPDATE user_stats s
SET ave_price = x.ave_price
FROM x
WHERE x.user_id = s.user_id;
Be advised that while CTE for SELECT queries were introduced with PostgreSQL 8.4, CTE for data modification commands were only introduced with PostgreSQL 9.1:
Allow data-modification commands (INSERT/UPDATE/DELETE) in WITH clauses
Allow data-modification commands (INSERT/UPDATE/DELETE) in WITH clauses