reinisk22
3 weeks ago
104
1
General

How to index a non-unique column?

Posted 3 weeks ago by reinisk22

Hey,

I've got a table like this

INCREMENTAL_ID, ID, STRATEGY, POLICY_ID, ASSIGNED_AT, CREATED_AT, UPDATED_AT

The strategy column is a nonunique text string that I need to index to optimize a count query that's too slow at the moment, but I can't figure out how to go about this. The query I need to optimize looks like this

select count(id) as aggregate 
from `external_ids` 
where `strategy` = 'long_nono_unique_text_string' 
and `assigned_at` is not null;

Could someone please suggest some strategies on how this is usually done? Thanks!

Please sign in or create an account to participate in this conversation.