Junior — Middle
Can you explain the concept of selectivity in the context of databases?
sobes.tech AI
Answer from AI
Selectivity in the context of databases is a measure of how effectively a filtering condition (for example, in WHERE) reduces the number of rows that need to be processed.
High selectivity means that the condition filters out a small portion of data, allowing the database to use indexes and execute queries faster.
For example, if a table with a million records has a WHERE condition that selects only 10 records, the selectivity is high. If the condition selects half of the table, the selectivity is low.
In Go (Golang), when working with databases, selectivity affects query performance, especially when using ORM or writing SQL queries manually.