What I think is happening here is that the call to random() in your WHERE clause is happening once for each record examined. Instead, put the random logic into a subquery:
SELECT *
FROM
(
SELECT generate_series(1, 1030) AS id
) t
WHERE id = (SELECT FLOOR(RANDOM() * 1030 + 1));
By the way, the reason the above trick works is because Postgres' optimizer will execute the subquery once and cache the result. If it didn't do this, then the above would still suffer from the same problem you are currently seeing.