I use SELECT lastval() to get wrong serial id after truncated the table.
when I truncate the table, I use SELECT lastval(), I got the wrong ID/
Try
TRUNCATE TABLE table_name RESTART IDENTITY;
It will
Automatically restart sequences owned by columns of the truncated table(s).
Details here: TRUNCATE