On 14/10/10 17:28, Dan Kennedy wrote:
>
> On Oct 14, 2010, at 10:43 PM, Alan Chandler wrote:
>> CREATE TABLE div_winner_pick (
...
>>      PRIMARY KEY (cid,confid,divid,uid)
>> );

...
>>
>> CREATE INDEX div_win_pick_uid_cid_idx ON div_winner_pick (uid,cid);


...

> It should be clearer. Basically the index would be redundant
> if it contains the same columns in the same order as the primary
> key. Or a prefix thereof. i.e. the following indexes would be
> all be redundant (pure overhead for no benefit):
>
>      CREATE INDEX x ON div_pick_winner(cid);
>      CREATE INDEX x ON div_pick_winner(cid,confid);
>      CREATE INDEX x ON div_pick_winner(cid,confid,divid);
>      CREATE INDEX x ON div_pick_winner(cid,confid,divid,uid);
>
> Your index is not redundant though.

This is interesting - what if I changed the primary key to be

PRIMARY KEY (uid,cid,confid,divid)

Is that an optimisation that is useful to make?


-- 
Alan Chandler
http://www.chandlerfamily.org.uk
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to