Choosing the right indexes for a database involves adhering to three basic rules: usefulness, clustering, and scattering. Usefulness ensures that indexes speed up queries and enforce constraints, although they can slow down write operations. Clustering involves organizing records accessed together to minimize network operations, particularly important in distributed databases like CockroachDB. Scattering, however, keeps unrelated records apart to avoid hotspots and improve scalability. When selecting unique IDs, options include sequences, timestamps, and randomness, each with its trade-offs in terms of performance and scalability. Hash-sharded indexes are a unique feature in CockroachDB designed to handle sequential traffic by distributing it uniformly, thus avoiding single-range hotspots. They offer improved write performance for sequentially-keyed indexes while slightly affecting read performance, and can be created by enabling specific session variables and using SQL extensions.