improve lastlogin performance by using indexes, closes #1633, patch by lelutin