The pipe creates a subshell so the variables scopes outside the while loop are different. Adding () in this case is the easiest fix.
Code:
interfaces=(eth1)
i=0
## let's consider that from the query I have 4 rows
psql -U $user -d $database -t -c "select all interfaces'" |
( while read record; do
((i++))
interfaces[$i]=$record
echo $i #1
echo ${interfaces[*]} #2
done
echo $i #3
echo ${interfaces[*]} )#4
By the way your posted SQL statement syntax does not look correct. You have an extra single quote and you did not specify the table i.e.
"select all interfaces from table_name"