storage/db: add NOT NULL and PRIMARY KEY constraints to improve performance
In a test database containing 309,000 real benchmark records, given
select t1.UploadID, (select t2.Value from RecordLabels t2 where
t2.UploadID = t1.UploadID AND Name = 'upload-time' limit 1) from
used to obtain sample values from each upload, the PRIMARY KEY index
causes the query to fall from 1.49s to 0.03s.
The NOT NULL constraint is necessary to make the PRIMARY KEY effective.
Reviewed-by: Russ Cox <email@example.com>
1 file changed