Fixing index sql.