added more sql to generate indexes on layers